[eluser]Alexxz[/eluser]
Another solving method is to make own mysql driver, which improves CI
mysqlex_driver.php
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
require_once(BASEPATH.'database/drivers/mysql/mysql_driver.php');
class CI_DB_mysqlex_driver extends CI_DB_mysql_driver {
function _update($table, $values, $where)
{
foreach($values as $key => $val)
{
if( ! strpos($key, '=')){
$valstr[] = $key." = ".$val;
} else {
$valstr[] = $key;
}
}
return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where);
}
function _insert($table, $keys, $values)
{
$data = array_combine($keys, $values);
foreach($data as $key => $val)
{
if( ! strpos($key, '=')){
$valstr[] = $key." = ".$val;
} else {
$valstr[] = $key;
}
}
return "INSERT INTO ".$this->_escape_table($table)." SET ".implode(', ', $valstr);
}
}
The utility and result parts of driver just inherit standard mysql driver.
In configuration file $db['default']['dbdriver'] = "mysqlex";
Now i can write
Code:
$data = array();
$data['state'] = $newstate;
$data["changed = NOW() "] = null;
and the same syntax for $where statement (for $where works without this changes).
Also I want to make 'LIMIT' restrictions for 'DELETE' statement.