• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
spaces in MySQL columns

#1
[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!

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

#3
[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....

#4
[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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.