CodeIgniter 4 - Temporary tables |
Hi, guys!
Sometimes we need temporary tables to get a complex table created by code in CI4. Let's do it simple. $this->forge = \Config\Database::forge('default'); // see CI4 guide //If table already exists, let's drop it $this->forge->dropTable('my_temporary_table', true); // use any name you want //Adding fileds $this->forge->addField('id MEDIUMINT NOT NULL AUTO_INCREMENT'); $this->forge->addField('name VARCHAR(30)'); //Add primary key $this->forge->addKey('id',true); Pay attention! Here's the secret! $this->forge->createTable('my_temporary_table',false,['TEMPORARY TABLE']); For any additional help and sintax go to https://codeigniter.com/user_guide/dbmgmt/forge.html |
Messages In This Thread |
CodeIgniter 4 - Temporary tables - by Luís Andrade - 10-10-2022, 01:24 PM
RE: CodeIgniter 4 - Temporary tables - by InsiteFX - 10-11-2022, 12:53 AM
|