This article mainly introduces the CI framework AR operation to insert Multiple SQL data records, and analyzes the CI framework using arrays to insert multiple data records in the form of a simple example, for more information about how to insert Multiple SQL data records, see the example in this article. 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.php.net '), array ('name' => 'feet home', 'url' => 'HTTP: // www.php.net '); $ this-> db-> insert_batch ('mytable ', $ data );
The preceding SQL statement is as follows:
The Code is as follows:
Insert into mytable (name, url) VALUES ('php', 'HTTP: // www.php.net '), ('feet home', 'HTTP: // www.php.net ')
Summary: Data parameters in the database quick operation class in the ci framework are generally one-dimensional associated arrays..