[eluser]GreenDude[/eluser]
Hi.
I'm building an application that processes a xml file and creates a table accordingly.
The problem is that some columns have names that include spaces or dots, and the add_column function splits the name inside the query.
For example, if I try adding a field called "What the hell", I get the following error:
Code:
Error Number: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'the `hell` VARCHAR(225) NOT NULL' at line 2
ALTER TABLE `info` ADD `what` the `hell` VARCHAR(225) NOT NULL
Here's how my array looks like:
Code:
Array
(
[what the hell] => Array
(
[type] => VARCHAR
[null] =>
[constraint] => 225
)
)
And here's the chunk of php that does the work:
Code:
$fields = array();
$fields[$this->nume] = array( 'type' => strtoupper($this->tip), 'null' => FALSE );
if ( $this->restrictie != NULL ) $fields[$this->nume]['constraint'] = $this->restrictie;
else if ( $this->tip == 'varchar' ) $fields[$this->nume]['constraint'] = 225;
if ( $this->optional ) $fields[$this->nume]['null'] = TRUE;
$this->dbforge->add_column('info', $fields);
Any idea how I could make the query use the whole name?
GreenDude