- Details
-
Published on Thursday, 15 April 2004 00:00
-
Written by Admin
Page 3 of 9
hello_world.php - Frontend display
<?php
//hello_world Component//
/**
* Content code
* @package hello_world
* @Copyright (C) 2004 Doyle Lewis
* @ All rights reserved
* @ hello_world is Free Software
* @ Released under GNU/GPL License : http://www.gnu.org/copyleft/gpl.html
* @version 1.0
**/
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
global $database;
$query = "SELECT * FROM jos_hello_world LIMIT 1";
$database->setQuery( $query );
$rows = $database->loadObjectList();
$row = $rows[0];
echo $row->text;
?>
Now let's look at how the file works:
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
This makes sure Mambo is calling the file. Very important for security.
global $database;
Sets $database as a global variable so you can use it within your function.
$query = "SELECT * FROM jos_hello_world LIMIT 1";
Selects the first entry in the jos_hello_world table in the database.
$database->setQuery( $query );
Maps your query to the $database class.
$rows = $database->loadObjectList();
Creates a variable named $rows that stores all of the database information as an array.
$row = $rows[0];
Creates a variable named $row that stores only the first value in the $rows array.
echo $row->text;
Writes the value for text to the screen.
You have no rights to post comments