Table of Contents
Use the CI framework to implement simple additions, deletions, modifications and queries in the database. The ci framework
Home Backend Development PHP Tutorial Use the CI framework to implement simple additions, deletions, modifications and queries in the database, ci framework_PHP tutorial

Use the CI framework to implement simple additions, deletions, modifications and queries in the database, ci framework_PHP tutorial

Jul 13, 2016 am 09:46 AM
generation increase accomplish database check frame use of Simple

Use the CI framework to implement simple additions, deletions, modifications and queries in the database. The ci framework

The following code is based on CodeIgniter_version 2.1.3

Use PHP to implement simple addition, deletion, modification and query in the database (pure code) please click

http://www.cnblogs.com/corvoh/p/4641476.html

For compatibility issues between CodeIgniter_2.1.3 and PHP5.6, please click

http://www.cnblogs.com/corvoh/p/4649357.html

Added:

<span>//</span><span>insert<br /></span><span><span>//语法:$bool=$this->db->insert('表名',关联数组);<br /></span></span>
<span>$data</span>=<span>array</span><span>(
</span>    'username'=>'mary',
    'password'=>'mary',<span>//建立一个用户名叫mary,密码为mary的数组,并传递给变量$data</span><span>
);
</span><span>$bool</span>=<span>$this</span>->db->insert('user',<span>$data</span><span>);<span>//将$data插入数据库的user表中</span>
</span><span>var_dump</span>(<span>$bool</span>);<span>//成功则返回TURE</span>
Copy after login

Delete:

<span>//</span><span>delete<br />//语法:<span>$bool=$this->db->delete('表名',WHERE条件);</span></span>
<span>$bool</span>=<span>$this</span>->db->delete('user',<span>array</span>('id'=>3<span>));<span>//删除数据库.user表里id=3的用户所有信息</span>
</span><span>var_dump</span>(<span>$bool</span>);<span>//成功则返回TURE</span>
Copy after login


Change:

<span>//<span>update
<span>$data=<span>array<span>(
    'password'=>12345,<span>
);
<span>$bool=<span>$this->db->update('user',<span>$data,<span>array('id'=>3<span>));<span>//将数据库.user表里id=3的用户密码给为12345<br /></span><span>var_dump(<span>$bool);<span>//成功则返回TURE</span></span></span></span></span></span></span></span></span></span></span></span></span></span>
Copy after login

Check:

<span>//<span>get
<span>$res=<span>$list=<span>$this->db->get('user'<span>);
<span>//<span>var_dump($list);
<span>foreach(<span>$res->result() <span>as <span>$item<span>){<span>//利用foreach来列出所有用户名</span>
    <span>echo <span>$item-><span>username;
<span>echo '<br />'<span>;
}</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
Copy after login

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1034507.htmlTechArticleUse the CI framework to implement simple additions, deletions, modifications and queries to the database. The following code of the ci framework is based on CodeIgniter_2.1.3 version using PHP To implement simple additions, deletions, modifications and queries (pure code) in the database, please click http:/...
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos Jul 18, 2024 am 05:48 AM

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

How to evaluate the cost-effectiveness of commercial support for Java frameworks How to evaluate the cost-effectiveness of commercial support for Java frameworks Jun 05, 2024 pm 05:25 PM

Evaluating the cost/performance of commercial support for a Java framework involves the following steps: Determine the required level of assurance and service level agreement (SLA) guarantees. The experience and expertise of the research support team. Consider additional services such as upgrades, troubleshooting, and performance optimization. Weigh business support costs against risk mitigation and increased efficiency.

How to handle database connection errors in PHP How to handle database connection errors in PHP Jun 05, 2024 pm 02:16 PM

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.

How does the learning curve of PHP frameworks compare to other language frameworks? How does the learning curve of PHP frameworks compare to other language frameworks? Jun 06, 2024 pm 12:41 PM

The learning curve of a PHP framework depends on language proficiency, framework complexity, documentation quality, and community support. The learning curve of PHP frameworks is higher when compared to Python frameworks and lower when compared to Ruby frameworks. Compared to Java frameworks, PHP frameworks have a moderate learning curve but a shorter time to get started.

How do the lightweight options of PHP frameworks affect application performance? How do the lightweight options of PHP frameworks affect application performance? Jun 06, 2024 am 10:53 AM

The lightweight PHP framework improves application performance through small size and low resource consumption. Its features include: small size, fast startup, low memory usage, improved response speed and throughput, and reduced resource consumption. Practical case: SlimFramework creates REST API, only 500KB, high responsiveness and high throughput

How does Go WebSocket integrate with databases? How does Go WebSocket integrate with databases? Jun 05, 2024 pm 03:18 PM

How to integrate GoWebSocket with a database: Set up a database connection: Use the database/sql package to connect to the database. Store WebSocket messages to the database: Use the INSERT statement to insert the message into the database. Retrieve WebSocket messages from the database: Use the SELECT statement to retrieve messages from the database.

How to choose the best golang framework for different application scenarios How to choose the best golang framework for different application scenarios Jun 05, 2024 pm 04:05 PM

Choose the best Go framework based on application scenarios: consider application type, language features, performance requirements, and ecosystem. Common Go frameworks: Gin (Web application), Echo (Web service), Fiber (high throughput), gorm (ORM), fasthttp (speed). Practical case: building REST API (Fiber) and interacting with the database (gorm). Choose a framework: choose fasthttp for key performance, Gin/Echo for flexible web applications, and gorm for database interaction.

How to save JSON data to database in Golang? How to save JSON data to database in Golang? Jun 06, 2024 am 11:24 AM

JSON data can be saved into a MySQL database by using the gjson library or the json.Unmarshal function. The gjson library provides convenience methods to parse JSON fields, and the json.Unmarshal function requires a target type pointer to unmarshal JSON data. Both methods require preparing SQL statements and performing insert operations to persist the data into the database.

See all articles