Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Vinicius  >  Mysql DBObj  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: An example showing how does it works.
Class: Mysql DBObj
Compose and execute MySQL database SELECT queries
Author: By
Last change:
Date: 2004-05-30 17:45
Size: 1,056 bytes
 

Contents

Class file image Download
<?php
// Mysql connection class
// Made in 27/02/2004 by Vinícius Augusto Tagliatti Zani
// GPL License
//  <viniciustz@mtv.com.br>

include_once("Mysql.class.php");

// example of use:
$dbName "nome_do_banco";
$host "localhost";
$user "root";
$password "";

$query = new Mysql($host$user$password);
$query->selectDb($dbName);

$query->whereAdd("name = 'bob'");
$query->orderBy("name");
$query->limit(0,15);
$query->query("SELECT * FROM table");

echo 
"The query executed was:<BR>";
echo 
$query->finalQuery;
echo 
"<BR><BR>";

//////////////////////////////////////////////////
// 1st fetch method
while ($user $query->fetch()) {
    echo 
"Name: " $user->name "<BR>";
}
//////////////////////////////////////////////////

///////////////////////////////////////////////////
// 2nd fetch type
$new_query $query// clone
$new_query->find();
while (
$new_query->fetchToThis()) {
    echo 
"Name: " $new_query->name "<BR>";
}
//////////////////////////////////////////////////

echo "End.";
?>