CI framework AR operation (array form) to insert multiple SQL data, ciar_PHP tutorial

Source: Internet
Author: User
CI framework AR operations (array form) implement the method of inserting multiple SQL data, ciar. CI framework AR operations (array form) to insert multiple SQL data. ciar this article describes how to insert multiple SQL data using CI framework AR operations. For your reference, the CI framework AR operation (array form) implements the method of inserting 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:
The 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..

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.