<?php
# Version 1.0
require_once('../include/config.inc.php');
// ONLY MYSQL DB IS SUPPORTED RIGHT NOW
// This is automatically created in the config file
// You only need to do this if your connecting to another database that
// was not the default one specified in the config file
// Yes you can connect to multiple databases at the same time without having to
// open and close databases when switching between them
// Just use the object name given to each database....use a different object name for each!
$sql = new sql(DB_HOST,DB_NAME,DB_USER,DB_PASSWORD);
// Do any query
$sql->go("SELECT * FROM users");
// Fetch one result
$sql->fetchArray();
// Fetch all results
$sql->fetchAll();
// Number of results returned from query
$sql->numRows();
// Number of rows effects if query effected rows
$sql->affectedRows();
// Gets the last insert ID
$sql->lastId();
// Clear a result
$slq->clearResult();
// Close database connection
$slq->close();
#-------------------------------------------------------------------------------
# REFERENCES
#-------------------------------------------------------------------------------
// You can also use references with this class to call results from queries in any order
// unlike the above where your next query would override the previous and you couldn't call
// anymore results on the previous query
// The reference is set to "0" - zero, if not specified like in the above examples
// This is pretty much the same as above only with a second parameter with the query reference
// Do any query
$sql->go("SELECT * FROM users",'getusers');
$sql->go("INSERT users VALUES ('1','bla')",'user_insert');
// Fetch one result
$sql->fetchArray('getusers');
// Fetch all results
$sql->fetchAll('getusers');
// Number of results returned from query
$sql->numRows('getusers');
// Number of rows effects if query effected rows
$sql->affectedRows('user_insert');
// Gets the last insert ID
$sql->lastId('user_insert');
// Clear a result
$sql->clearResult('getusers');
$sql->clearResult('user_insert');
?>
|