Simple class to create insert and update statements. Independent of the access to the database. Makes handling complex inserts easier - especially when the table structure is liable to change.
<?php
////////////////////////////////////////////////////////////
// CreateSQL 0.1
// class for creating SQL statements independant of the database
// not always appropriate to create the SQL within the db class
// Makes complex inserts easier to manage - visually easier editing
//
// Sarah King
// sarah@pcpropertymanager.com
// http://www.pcpropertymanager.com
//
//
// $sql = new CreateSQL("mytable","mytableid");
// $sql->set_fields( array( "name" => $username,
// "email" => $email,
// "phone" => $tel,
// "fax" => $fax,
// "address" => $address,
// "postcode" => $postcode,
// "country" => $country,
// ));
//
// then use database class to run the query
// $db->query($sql->getUpdateSQL());
//
////////////////////////////////////////////////////////////
class CreateSQL
{
/**************************************************************************
********
Create Insert and update clauses based on data passed.
***************************************************************************
*******/
var $aFields = array();
var $tablename;
var $primarykey;
var $primarykeyvalue;
var $whereClause = "";