| 
<?php
/*
 Sample use
 */
 
 include('myquery.class.php');
 
 $q = new MyQuery();
 $q->setAction('SELECT');
 $q->setTable('article_table');
 $q->setCondition("status='published'");
 $q->setOrder('time','DESC');
 echo $q->getQuery().'<br />';
 // SELECT * FROM article_table WHERE status='published'
 
 $q->setCondition("author='John'");
 $q->setField('id');
 $q->setField('intro');
 echo $q->getQuery().'<br />';
 // SELECT id, intro FROM article_table
 // WHERE status='published' AND author='John'
 
 $q->initVars();
 $q->setAction('INSERT');
 $q->setTable('article_table');
 $q->setInsert('id','');
 // we'll use auto_incement - no need for specific id
 $q->setInsert('author','Peter');
 $q->setInsert('title','The great article');
 $q->setInsert('intro','This is an intro for the great article.');
 $q->setInsert('content','This is the content of the great article.');
 $q->setInsert('time',time());
 echo $q->getQuery().'<br />';
 // INSERT INTO article_table (id, author, title, intro, content, time)
 // VALUES ('', 'Peter', 'The great article', 'This is an intro for the great article.',
 // 'This is the content of the great article.', '1047987853')
 
 $q->initVars();
 $q->setAction('UPDATE');
 $q->setTable('rakstu_tabula');
 $q->setUpdate('autors','Juris Jura dēls');
 $q->setCondition("autors='Juris'");
 $q->setCondition("status='publicets'");
 echo $q->getQuery().'<br />';
 // UPDATE rakstu_tabula SET autors='Juris Jura dēls'
 // WHERE autors='Juris' AND status='publicets'
 
 
 $q->initVars();
 $q->setAction('DELETE');
 $q->setTable('rakstu_tabula');
 $q->setCondition("status='novecojis'");
 echo $q->getQuery().'<br />';
 // DELETE FROM rakstu_tabula WHERE status='novecojis'
 
 /*
 All these were simple queries on one table, here is
 another one, working on two tables.
 */
 
 $q = new MyQuery();
 $q->setAction('SELECT');
 $q->setTable('articles','a');
 $q->setTable('topics','t');
 $q->setTable('writers','w');
 $q->setCondition("a.aid=t.aid");
 $q->setCondition("a.aid=w.aid");
 $q->getQuery();
 ?>
 |