Home >Backend Development >PHP Tutorial >PHP CI framework inserts one or more sql records example_PHP tutorial

PHP CI framework inserts one or more sql records example_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 10:21:47811browse

Example of inserting one or more sql records in the php CI framework

This section mainly introduces how to insert one or more sql records in the php CI framework. The sample code is as follows. Friends who know it should not miss it

1. Insert a record

 $data = array(

'title' => 'My title' ,

'name' => 'My Name' ,

'date' => 'My date'

 );

$this->db->insert('mytable', $data);

// Produces: INSERT INTO mytable (title, name, date) VALUES ('My title', 'My name', 'My date')

2. Insert multiple records

 $data = array(

array(

'title' => 'My title' ,

'name' => 'My Name' ,

 'date' => 'My date'

 ),

array(

'title' => 'My title1' ,

'name' => 'My Name1' ,

'date' => 'My date1'

 )

 );

$this->db->insert_batch('mytable', $data);

// Produces: INSERT INTO mytable (title, name, date) VALUES ('My title', 'My name', 'My date'), ('My title1', 'My name1', 'My date1' )

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/852828.htmlTechArticlephp CI framework inserts one or more sql record examples. This section mainly introduces how to insert a sql record in the php CI framework. Or multiple sql records, the sample code is as follows, if you don’t understand, don’t miss it...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn