Well, I'd think you could just add the methods delete(), update(), insert(), and select()...
For example a delete might look like:
/**
* Delete selected row(s) from table
*
* @param $table string Table name to delete row(s) from
* @param $conditions array Conditions needed for rows to be deleted
* @param $limit int Maximum number of rows to delete (default: 1)
* @return boolean
*/
function delete($table, $conditions=array(), $limit=1)
{
$sql = "DELETE FROM `".$table."` ";
$sql .= $this->buildConditionsClause($conditions);
$sql .= "LIMIT ". $limit;
$result = mysql_query($query);
if(!$result || mysql_affected_rows() < $limit)
return false;
return true;
}
/**
* Dynamically build a WHERE clause based upon conditions given
*
* @param $conditions array Array of conditions
* @return string
*/
function buildConditionsClause($conditions)
{
// No conditions, return an empty string
if(empty($conditions))
return '';
$sql = "WHERE ";
$connector = false;
foreach($conditions as $key=>$val)
{
if(!is_array($val))
{
if($connector)
$sql .= "AND ";
$sql. = "`".$key."` = '".$val."' ";
$connector = true;
}
else
{
$type = $key;
foreach($val as $key=>$val2)
{
if($connector)
$sql .= strtoupper($type)." ";
$sql .= "`".$key."` = '".$val2."' ";
$connector = true;
}
}
}
return $sql;
}
You should then be able to pass in arrays like:
<?php
$conditions = array(
'column1' => 'some value',
'column2' => 'some other value',
);
// Or to use OR ...
$conditions = array(
'or' => array(
'column1' => 'some value',
'column2' => 'some other value'
),
);
It's mimicked of cakePHP's conditions; albeit, very very simplified. Anyway, you can do much the same thing with select, update, and insert statements.