[eluser]chejnik[/eluser]
Yet another question.
I would like to create table using Forge class using mysql database driver
Code:
function create_Structure_User($tableName)
{
$this->load->dbutil(); // note - $this->load->dbforge(); doesnot work
$fields = array(
'nickname' => array(
'type' => 'VARCHAR',
'constraint' => '40'
),
'password' => array(
'type' => 'VARCHAR',
'constraint' => '40'
),
'realName' => array(
'type' => 'VARCHAR',
'constraint' => '40'
),
'email' => array(
'type' => 'VARCHAR',
'constraint' => '40'
),
'street' => array(
'type' => 'VARCHAR',
'constraint' => '40'
),
'psc' => array(
'type' => 'VARCHAR',
'constraint' => '40'
),
'town' => array(
'type' => 'VARCHAR',
'constraint' => '40'
),
'country' => array(
'type' => 'VARCHAR',
'constraint' => '40'
),
'timezone' => array(
'type' => 'VARCHAR',
'constraint' => '40'
),
'phone' => array(
'type' => 'VARCHAR',
'constraint' => '40'
),
'alternativePhone' => array(
'type' => 'VARCHAR',
'constraint' => '40'
),
'msn' => array(
'type' => 'VARCHAR',
'constraint' => '40'
),
'icq' => array(
'type' => 'VARCHAR',
'constraint' => '40'
),
'alternativeEmail' => array(
'type' => 'VARCHAR',
'constraint' => '40'
),
'web' => array(
'type' => 'VARCHAR',
'constraint' => '40'
),
'notes' => array(
'type' => 'TEXT'
)
);
print_r($fields);
$this->dbforge->add_field($fields);
$this->dbforge->create_table($tableName, TRUE);
}
The result of print_r
Array ( [nickname] => Array ( [type] => VARCHAR [constraint] => 40 ) [password] => Array ( [type] => VARCHAR [constraint] => 40 ) [realName] => Array ( [type] => VARCHAR [constraint] => 40 ) [email] => Array ( [type] => VARCHAR [constraint] => 40 ) [street] => Array ( [type] => VARCHAR [constraint] => 40 ) [psc] => Array ( [type] => VARCHAR [constraint] => 40 ) [town] => Array ( [type] => VARCHAR [constraint] => 40 ) [country] => Array ( [type] => VARCHAR [constraint] => 40 ) [timezone] => Array ( [type] => VARCHAR [constraint] => 40 ) [phone] => Array ( [type] => VARCHAR [constraint] => 40 ) [alternativePhone] => Array ( [type] => VARCHAR [constraint] => 40 ) [msn] => Array ( [type] => VARCHAR [constraint] => 40 ) [icq] => Array ( [type] => VARCHAR [constraint] => 40 ) [alternativeEmail] => Array ( [type] => VARCHAR [constraint] => 40 ) [web] => Array ( [type] => VARCHAR [constraint] => 40 ) [notes] => Array ( [type] => TEXT ) )
An Error Was Encountered
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 ' `nameRealProject` VARCHAR(100), `nicknameAdmin` VARCHAR(40), `passwordAdmin`' at line 2
CREATE TABLE IF NOT EXISTS Project ( Array, `nameRealProject` VARCHAR(100), `nicknameAdmin` VARCHAR(40), `passwordAdmin` VARCHAR(40), `passwordProject` VARCHAR(40), `emailAdmin` VARCHAR(40), PRIMARY KEY (`id`) ) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
Please note the in sql statement at the beginning the word Array - I have no idea how to put it away. Seems to come from mysql.forge.php.