<?
##################################
# Select Example
##################################
require('mysql.php');
$mysql = new mysql();
## Example 1 ##
//Create new sql obj
$node = new sqlNode();
//Select 1 Row From Table into Assoc Array
$node->table = "members";
$node->select = "*";
$node->where = "where MemberID = 1";
// Execute query and store results
if(($memberInfo = $mysql->select_assoc($node)) === false )
die($mysql->debugPrint());
echo "You selected ".$memberInfo['FName']." ".$memberInfo['LName'];
## Example 2 ##
//Create new sql obj
$node = new sqlNode();
//Select Contents of Table and Order by Asc
$node->table = "members";
$node->select = "*";
$node->orderby = "order by `LName` asc Limit 20";
// Execute query and store results
if(($membersRS = $mysql->select($node)) === false )
die($mysql->debugPrint());
echo mysql_num_rows($membersRS) "Member(s) Found <hr/>";
//For each member
while( $member = mysql_fetch_assoc($membersRS) ){
echo $member['FName'] . " " . $member['LName'] . "<br/>";
}
?>
|