[SOVED] MySql Query Update With White Space Field in Query Builder Codeigniter
Okay, I updated the code in /system/database/DB_driver.php by modifying the code in the _update function.
From the initial code as follows:
protected function _update($table, $values)Becomes
{
foreach ($values as $key => $val) {
$valstr[] = $key . ' = ' . $val;
}
return 'UPDATE ' . $table . ' SET ' . implode(', ', $valstr)
. $this->_compile_wh('qb_where')
. $this->_compile_order_by()
. ($this->qb_limit ? ' LIMIT ' . $this->qb_limit : '');
}
protected function _update($table, $values)
{
foreach ($values as $key => $val) {
$key = str_replace('` `', ' ', $key);
$valstr[] = $key . ' = ' . $val;
}
return 'UPDATE ' . $table . ' SET ' . implode(', ', $valstr)
. $this->_compile_wh('qb_where')
. $this->_compile_order_by()
. ($this->qb_limit ? ' LIMIT ' . $this->qb_limit : '');
}
this method helps me update using a query builder on columns that have whitespaces.
![[SOVED] MySql Query Update With White Space Field in Query Builder Codeigniter [SOVED] MySql Query Update With White Space Field in Query Builder Codeigniter](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinoZMsIgnRFNARlJDX9kScn18TtBkMmZTnpKIf3Z61XUTuXmWd10jK4p0PdfWRWVSd6kVZ0x6WHx63Neagu0sipTFdjapsA5j6hLiHf5gJX0jOp3i4ovwAgAk7rb3AJyAelDBuS34Gb6Br/s400/Screenshot+from+2020-03-22+12-36-45.png)
![[SOVED] Codeigniter : Insert Mysql With Whitespace Field [SOVED] Codeigniter : Insert Mysql With Whitespace Field](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2L3_oEBJhGfkVa558iSaIAq8rGwrjU4ail60rYklGU4m3Kf705KkL_EbavMqr8RVnYhqyjNnaPQMtGcwp2wC9fR-rCF1oy4VHWcDdJij5h27JF-nZIidxuFoUlCcacdzM_asizoL5JUjl/s320/Screenshot+from+2020-03-22+12-07-32.png)