search
Homephp教程php手册php之CodeIgniter学习笔记

本篇文章是对php中的CodeIgniter进行了详细的分析介绍,需要的朋友参考下

在使用数据库之前,我们最好将数据库进行自动连接:config/autoload.php自动加载 $autoload['libraries'] = array('database');
一些常用函数

选择数据

插入数据

更新数据

$this->db->update_batch();
Generates an update string based on the data you supply, and runs the query. You can either pass an array or an object to the function. Here is an example using an array:

删除数据

链式方法


查询

转义查询

查询辅助函数


生成查询记录集

$row = $query->row(4);


结果集辅助函数

$query->num_rows()
该函数将会返回当前请求的行数。
$query->num_fields()
该函数返回当前请求的字段数(列数):
$query->free_result()
该函数将会释放当前查询所占用的内存并删除其关联的资源标识。

自动连接


$autoload['libraries'] = array('database');

手动连接

如果仅仅是一部分页面要求数据库连接,你可以在你有需要的函数里手工添加如下代码或者在你的类里手工添加以供该类使用。
$this->load->database();

连接多数据库

表数据

$this->db->list_tables();
返回一个包含当前连接数据库中所有表名称的数组。
$this->db->table_exists();
有时,网站空间,在对某个表执行操作之前,使用该函数判断指定表是否存在很有用。返回一个布尔值

数据库工具类


一旦初始化完毕,美国空间,你可以通过 $this->dbutil 对象来访问成员函数:
$this->dbutil->list_databases()
$this->dbutil->database_exists();
$this->dbutil->xml_from_result($db_result)
$this->dbutil->backup()

数据库缓存类



一旦被激活,每一次含有数据库查询的页面被加载时缓存就会自动发生。


$this->db->cache_delete_all()
清除所有所有的缓存文件。

数据库维护类


,香港空间
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

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)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function