Dbforge alter add column always create NOT NULL field - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: CodeIgniter 2.x (https://forum.codeigniter.com/forumdisplay.php?fid=18) +--- Thread: Dbforge alter add column always create NOT NULL field (/showthread.php?tid=65529) |
Dbforge alter add column always create NOT NULL field - madaweb - 06-22-2016 Hi! The query of ALTER TABLE ADD COLUMN is automatically concatened by NOT NULL in CodeIgniter working with PostgreSQL PHP Code: $this->dbforge = new CI_DB_postgre_forge; So I always got an error message when there is already data inside the table: i'm using a french computer ERREUR: la colonne « location » contient des valeurs NULL ALTER TABLE "data"."circuits" ADD "location" integer NOT NULL How to avoid this ? RE: Dbforge alter add column always create NOT NULL field - madaweb - 07-05-2016 I don't know if it is a bug but I add these lines when I call for add_column or _alter_table() now: PHP Code: if (substr($sql, -8, 8) == "NOT NULL") { Remove the last NOT NULL text in CodeIgniter-built query RE: Dbforge alter add column always create NOT NULL field - mwhitney - 07-07-2016 https://codeigniter.com/userguide2/database/forge.html PHP Code: $field = array( You shouldn't be calling _alter_table() directly, but, if you need to call it directly for some reason, you should look at the function definition, because the ~6th argument controls whether the field is defined with ' NULL' or ' NOT NULL'. RE: Dbforge alter add column always create NOT NULL field - madaweb - 07-08-2016 Thanks for your return. I am newbie with CI so I didn't dare to step inside CI system codes! |