Problem/Error with DB Forge table creation. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Problem/Error with DB Forge table creation. (/showthread.php?tid=14088) |
Problem/Error with DB Forge table creation. - El Forum - 12-17-2008 [eluser]Hickeroar[/eluser] Code: $this->dbforge->add_field("`app_id` int(11) NOT NULL auto_increment"); If I remove lines 1 & 3, it works. Creates the apps table and puts in the app_name field. If I remove just line 3, obviously it dies because you have to define the auto-increment field as a primary key. if I leave it as-is, it gives me this: Quote:A PHP Error was encountered Is this a bug in DB Forge? DB is MySQL 4.X Problem/Error with DB Forge table creation. - El Forum - 12-18-2008 [eluser]cbosuna[/eluser] I found the problem and here is a patch, can someone on the CodeIgniter team please apply? --- a/system/database/drivers/mysql/mysql_forge.php +++ b/system/database/drivers/mysql/mysql_forge.php @@ -154,8 +154,8 @@ class CI_DB_mysql_forge extends CI_DB_forge { if (count($primary_keys) > 0) { $key_name = $this->db->_protect_identifiers(implode('_', $primary_keys)); - $primary_keys = $this->db->_protect_identifiers($primary_keys); - $sql .= ",\n\tPRIMARY KEY ".$key_name." (" . implode(', ', $primary_keys) . ")"; + $primary_keys = $this->db->_protect_identifiers(implode(', ', $primary_keys)); + $sql .= ",\n\tPRIMARY KEY ".$key_name." (" . $primary_keys . ")"; } if (is_array($keys) && count($keys) > 0) Problem/Error with DB Forge table creation. - El Forum - 12-18-2008 [eluser]sl3dg3hamm3r[/eluser] If you think it is a bug, maybe you should post it in the bug-section... Problem/Error with DB Forge table creation. - El Forum - 12-18-2008 [eluser]cbosuna[/eluser] I did. Was not familiar with CI community policy. Problem/Error with DB Forge table creation. - El Forum - 12-18-2008 [eluser]Hickeroar[/eluser] Thanks friend. Worked like a charm. I guess DBForge isn't used too much for table creation? Strange that something like this got missed. |