CodeIgniter Forums
spaces in MySQL columns - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: spaces in MySQL columns (/thread-9854.html)



spaces in MySQL columns - El Forum - 07-10-2008

[eluser]exodus7[/eluser]
I'm having trouble inserting a record using the Active Record Class when the column name has a space in it. I've tried using brackets & '' but its not working as expected:

example:

Code:
$data = array('Constituent Name' => $this->input->post('fullName', TRUE))

$this->db->insert('mis', $data);

This is actually the first time I've seen spaces in a table's filed name I don't know how to fix this...

Any help would be greatly appreciated. Thanks!


spaces in MySQL columns - El Forum - 07-10-2008

[eluser]xpix[/eluser]
change the table name


spaces in MySQL columns - El Forum - 07-10-2008

[eluser]exodus7[/eluser]
its not the table name that is the problem, its the field in the table that has the space - and I can't change the name because the database is used by other applications which I have no control over....


spaces in MySQL columns - El Forum - 07-10-2008

[eluser]Randy Casburn[/eluser]
that's an unfortunate poor design that's been thrust upon you.

You must use backticks to surround your column name. You'll also have to finagle those through your PHP and JS string sanity and validation checks.

Best of luck.

Randy