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