CI Framework ar operation (array form) implements the method of inserting multiple SQL data, ciar_php tutorial

Source: Internet
Author: User
Tags codeigniter zend framework

CI Framework ar operation (array form) implements the method of inserting multiple SQL data, Ciar


In this paper, we describe a method for inserting multiple SQL data with CI framework ar operation. Share to everyone for your reference, as follows:

If you don't use AR, you can do this:

INSERT into TABLE VALUES (' 1 ', ' 2 '), (' 3 ', ' 4 '), $this->db->query ($sql);

Individual or like the CI ar operation, the old version (2.0) should not insert more than one data operation, the new version can be used:

$this->db->insert_batch ();

The following cases:

$data = Array (  ' name ' = ' PHP ',  ' url ' = ' http://www.bkjia.com '), Array (  ' name ' = ' home for help '), c3/> ' url ' = ' http://www.bkjia.com '); $this->db->insert_batch (' mytable ', $data);

The SQL generated above is like this:
Copy the code as follows: INSERT into mytable (name, URL) VALUES (' PHP ', ' http://www.bkjia.com '), (' Home for the guests ', ' http://www.bkjia.com ')

Summary:data parameters in a database shortcut action class in the CI framework are generally one-dimensional associative arrays .

More interested in CodeIgniter related content readers can view this site topic: "CodeIgniter Introductory Tutorial", "CI (codeigniter) Framework Advanced Tutorial", "PHP Excellent Development Framework Summary", "thinkphp Getting Started", " Summary of common methods of thinkphp, "Introduction to Zend Framework Frame", "Introduction to PHP Object-oriented Programming", "Introduction to Php+mysql Database Operation" and "PHP common database Operation Skills Summary"

It is hoped that this article is helpful to the PHP program design based on CodeIgniter framework.

http://www.bkjia.com/PHPjc/1127856.html www.bkjia.com true http://www.bkjia.com/PHPjc/1127856.html techarticle CI framework ar operation (array form) implements the method of inserting multiple SQL data, Ciar The example of CI framework AR operation Implementation of inserting multiple SQL data. Share to everyone for your reference, ...

  • 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.