Home > php教程 > php手册 > php CI框架插入一条或多条sql记录示例

php CI框架插入一条或多条sql记录示例

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 09:27:56
Original
909 people have browsed it

php CI框架插入一条或多条sql记录示例

   本节主要为大家介绍了php CI框架如何插入一条或多条sql记录,示例代码如下,不了解的朋友不要错过

  1、插入一条记录

  $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、插入多条记录

  $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')

Related labels:
Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template