Using CI framework to implement simple additions and deletions in database

Source: Internet
Author: User

The following code is based on version codeigniter_2.1.3

Use PHP to implement simple additions and deletions to the database (pure code) please poke


codeigniter_2.1.3 and PHP5.6 compatibility issues please poke



// Insert
Syntax: $bool = $this->db->insert (' table name ', associative array);
$data=array( ' username ' = ' mary ', ' password ' = ' Mary ',// Create an array of the user named Mary, whose password is Mary, and pass it to the variable $data); $bool=$this->db->insert (' user ',$data); Insert the $data into the user table of the database var_dump($bool); //Success returns ture

By deleting:

// Delete
Syntax:$bool = $this->db->delete (' table name ', where condition); $bool=$this->db->delete (' user ',array(' id ' =>3)); Delete the database. User list id=3 All information var_dump($bool); //Success returns ture


update$data =array(    ' password ' =>12345,);  $bool =$this->db->update (' user ',$data,array (' ID ' =>3));  Give the user password for the database. Id=3 to 12345
Var_dump ($bool); Success returns ture


get$res =$list =$this->db->get (' user ');  Var_dump ($list); foreach ($item) {//Use foreach to list all user names $item, username;  echo ' <br/> ';}             

Using CI framework to implement simple additions and deletions in database

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