<?php
require_once('mquery.class.php');
// generate query for table people, // use conditions for username and haircolor // order by realname
$q=new mquery('people','username like "a%",haircolor="blue"','realname');
// generate a delete query based on defined conditions echo "1: ".$q->genquery('delete')."<br>\n";
// OUTPUT: // 1: DELETE FROM people WHERE ((username like "a%") AND (haircolor="blue"))
// drop haircolor condition $q->unsetcondition('haircolor');
// add new evaluations $q->setkey('shoesize','36'); $q->setkey(array( 'haircolor'=>'yellow', 'eyecolor'=>'blue'));
// generate an insert query echo "2: ".$q->genquery('insert')."<br>\n";
// OUTPUT: // 2: INSERT INTO people SET shoesize='36', haircolor='yellow', eyecolor='blue'
// add new haircolor condition $q->setcondition('haircolor=10');
// drop eyecolor evaluation $q->unsetkey('eyecolor');
// generate an update query echo "3: ".$q->genquery('update')."<br>\n";
// OUTPUT: // 3: UPDATE people SET shoesize='36', haircolor='yellow' WHERE ((username like "a%") AND (haircolor=10))
// generate a select query echo "4: ".$q->genquery('select')."<br>\n";
// OUTPUT: // 4: SELECT shoesize, haircolor FROM people WHERE ((username like "a%") AND (haircolor=10)) ORDER BY realname
?>
|