Welcome Guest, Not a member yet? Register   Sign In
[split] Annoying column? CodeIgniter 3.1.9 released
#1

$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?
Reply
#2

(This post was last modified: 01-17-2019, 09:36 AM by InsiteFX.)

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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

@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.
Reply
#4

To use in a mysql query you would need to escape the "annoying column"

using backtick marks `annoying column`
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB