PHP Classes

File: example.php

Recommend this page to a friend!
  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: 20 years ago
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
// <[email protected]>

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.";
?>