Login   Register  
PHP Classes
elePHPant
Icontem

File: select_example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of dan boorn  >  OO Mysql Wrapper  >  select_example.php  >  Download  
File: select_example.php
Role: Example script
Content type: text/plain
Description: Select Example
Class: OO Mysql Wrapper
MySQL database SQL queries wrapper
Author: By
Last change:
Date: 2006-07-29 15:43
Size: 1,123 bytes
 

Contents

Class file image Download
<?
    
##################################
    # 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/>";
    }
    
?>