I need to do trim before inserting into database. I am using codeigniter . Now if i have to do trim before inserting , then i have to make code change across project . So i thought to do trim before insertion operation executed by codeigniter .
In system/database/drivers/mysql/mysql_driver.php in the _insert function i introduced a forloop to trim the data in array . The code is as follows .
function _insert($table, $keys, $values){
$arr = array();
foreach($values as $k => $v)
$arr[$k] = trim($v);
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $arr).")";
}
Any guidance is appreciated . After inserting if i see the value database it is not trimmed. The same while i could see in the log file.