CodeIgniter Forums
Problem with forge - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Problem with forge (/showthread.php?tid=37547)



Problem with forge - El Forum - 01-13-2011

[eluser]caperquy[/eluser]
Hi
I try to create a table using the following code :
Code:
$fields = array
            (
                'mytable' => array
                    (
                         'type' => 'VARCHAR',
                         'constraint' => '100',
                         'character set' => 'latin1',
                         'collate' => 'latin1_swedish_ci'
                      ),
            );
            $this->dbforge->add_field($fields);
        $this->dbforge->create_table('mytable');

Who can explain that the generated SQL is as follows :

CREATE TABLE `mytable` (
`myfield` VARCHAR(100)
) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;"
Thanks for the answer
CapErquy


Problem with forge - El Forum - 01-13-2011

[eluser]c77m[/eluser]
I haven't used it myself, but the user guide doesn't seem to reflect the ability to apply column-level character set. (http://ellislab.com/codeigniter/user-guide/database/forge.html#add_field)

Also, I'm confused where the "myfield" column comes from in the SQL, because the only field you specified is called "mytable".


Problem with forge - El Forum - 01-13-2011

[eluser]caperquy[/eluser]
Thanks for the answer. I feel that the forge solution is not reliable and I have seen in the forum that some bugs have bben reported. Therefore I have decided to forget that approach and to use directly the SQL structure for the table creation.
CapErquy