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
MySQLTUTORIAL - MySQL Temporary Table
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |