<?php
/* Version 1
* Please leave this comment in at the top of the script if you use this script
* in it's entirety. That is my only request. Other then that have fun.
*
* Bobo's Simple SQL Builder Class
* http://www.phpclasses.org/package/7306-PHP-Simple-SQL-Query-Building-Class.html
*
*
* also check out my db access class (Bobo DB) for easy database access in PHP:
* http://www.phpclasses.org/package/5283-PHP-Simple-MySQL-database-access-wrapper.html
*
* I created this class to simplify queries to and from the database. Instead of a whole bunch of
* redundant lines of code this makes your code cleaner and easier to understand.
*
* also check out my websites:
* http://insidefame.com
* http://wellerit.com
*
* Also if you're looking for help from me directly you can usually find me
* slumming it on #phphelp on the undernet irc network.
*
*
*/
include_once('class.sql.builder.php');
$s = new sql_builder();
echo "<hr />";
// example 1 - update //
$s->update->table('mytable');
$s->update->set("myval", "'5'");
$s->update->set("myval2", "'25'");
$s->update->where("id=5");
$s->update->limit(1);
echo $s->update->sql();
echo "<hr />";
// example 2 - insert //
$s->insert->table('mytable');
$s->insert->set("myval", "'5'");
$s->insert->set("myval2", "'25'");
echo $s->insert->sql();
echo "<hr />";
// example 3 - delete //
$s->delete->table('mytable');
$s->delete->where("id=5");
echo $s->delete->sql();
echo "<hr />";
// example 4 - select //
$s->select->table('mytable');
$s->select->cols('id,name');
$s->select->where('id=5');
$s->select->limit(1);
echo $s->select->sql();
echo "<hr />";
// example 5 - select //
$s->select->table('mytable');
echo $s->select->sql();
?>
|