Welcome Guest, Not a member yet? Register   Sign In
Database Forge add_column query problem
#1

[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


Messages In This Thread
Database Forge add_column query problem - by El Forum - 04-21-2008, 09:50 AM
Database Forge add_column query problem - by El Forum - 04-21-2008, 11:57 AM
Database Forge add_column query problem - by El Forum - 04-21-2008, 12:45 PM
Database Forge add_column query problem - by El Forum - 04-21-2008, 02:38 PM
Database Forge add_column query problem - by El Forum - 04-21-2008, 04:20 PM



Theme © iAndrew 2016 - Forum software by © MyBB