CI framework AR operation (array form) to insert Multiple SQL data, ciar
This article describes how to insert Multiple SQL data records using the CI framework AR operation. We will share this with you for your reference. The details are as follows:
If you do not use AR, you can do this:
Insert into table (FIELDS) VALUES ('1', '2'), ('3', '4'); $ this-> db-> query ($ SQL );
I personally like the AR operation of CI. In the old version (about 2.0), there should be no operation to insert multiple data entries. The new version can be used:
$ This-> db-> insert_batch ();
Example:
$ Data = array ('name' => 'php', 'url' => 'HTTP: // www.bkjia.com '), array ('name' => 'customer home', 'url' => 'HTTP: // www.bkjia.com '); $ this-> db-> insert_batch ('mytable ', $ data );
The preceding SQL statement is as follows:
Copy codeThe Code is as follows: insert into mytable (name, url) VALUES ('php', 'HTTP: // www.bkjia.com '), ('customer home', 'HTTP: // www.bkjia.com ')
Summary: Data parameters in the database quick operation class in the ci framework are generally one-dimensional associated arrays..