CodeIgniter Forums

Full Version: [split] Annoying column? CodeIgniter 3.1.9 released
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
$primary_column_has_space = "annoying column";
$value = "value of column";
$data = array("column_one"=>"value one");

$this->db->where("`".$primary_column_has_space."`", $value);
$this->db->update("annoying_table", $data);
echo $this->db->last_query();
Output : Update `annoying_table` set `column_one`='value one' where `annoying column` 'value of column';


$this->db->where("`".$primary_column_has_space."` =", $value);
$this->db->update("annoying_table", $data);
echo $this->db->last_query();
Output : Update `annoying_table` set `column_one`='value one' where `annoying` `column` = 'value of column';


$this->db->where("`".$primary_column_has_space."` = ".$value);
$this->db->update("annoying_table", $data);
echo $this->db->last_query();
Output : Update `annoying_table` set `column_one`='value one' where `annoying` `column` = 'value of column';



Codeigniter is not support for update where column name has space? any solution?
A space in any database field name / column name is not allowed!

Use an underscore annoying_column

If this is for CodeIgniter 3.1.9 then you post this in the wrong Forum Topic.
@buzzlee,

What database are you using? Mysql? Postgresql? From what I understand MySQL does allow spaces in column names. Putting spaces in column names is BAD practice.
To use in a mysql query you would need to escape the "annoying column"

using backtick marks `annoying column`