예배 규칙서 찾다
Array Array Helper Benchmarking Benchmarking Class Caching Caching Driver Calendaring Calendaring Class CAPTCHA CAPTCHA Helper Config Config Class Cookie Cookie Helper Database Connecting to your Database Custom Function Calls Database Caching Class Database Configuration Database Forge Class Database Metadata Database Quick Start: Example Code Database Reference Database Utility Class DB Driver Reference Generating Query Results Queries Query Builder Class Query Helper Methods Transactions Date Date Helper Directory Directory Helper Download Download Helper Email Email Class Email Helper Encrypt Encrypt Class Encryption Encryption Library File File Helper File Uploading File Uploading Class Form Form Helper Form Validation Form Validation FTP FTP Class Functions compatibility_functions common_functions HTML HTML Helper HTML Table HTML Table Class Image Manipulation Image Manipulation Class Inflector Inflector Helper Input Input Class Javascript Javascript Class Language Language Class Language Helper Loader Loader Class Migrations Migrations Class Number Number Helper Output Output Class Pagination Pagination Class Path Path Helper Security Security Class Security Helper Session Session Library Shopping Cart Shopping Cart Class Smiley Smiley Helper String String Helper Template Parser Template Parser Class Text Text Helper Trackback Trackback Class Typography Typography Class Typography Helper Unit Testing Unit Testing Class URI URL User Agent XML XML-RPC and XML-RPC Server Zip Encoding Zip Encoding Class XML-RPC and XML-RPC Server Classes XML Helper User Agent Class URL Helper URI Class
문자

执行查询的信息

$这个 - > DB-> INSERT_ID()

执行数据库插入时的插入ID号。

如果在PostgreSQL中使用PDO驱动程序,或者使用Interbase驱动程序,则此函数需要一个$name参数,该参数指定检查插入id的适当顺序。

$this - > DB-> affected_rows()

显示执行“写入”类型查询(插入,更新等)时受影响的行数。

在MySQL中,“DELETE FROM TABLE”返回0个受影响的行。数据库类有一个小黑客,它允许它返回正确数量的受影响的行。默认情况下,此hack已启用,但可以在数据库驱动程序文件中关闭。

$这个 - > DB-> last_query()

返回运行的最后一个查询(查询字符串,而不是结果)。例:

$str = $this->db->last_query();// Produces: SELECT * FROM sometable....

禁用数据库配置中的save_queries设置将使此功能无效。

有关数据库的信息

$这个 - > DB-> count_all()

允许您确定特定表中的行数。在第一个参数中提交表名。例子:

echo $this->db->count_all('my_table');// Produces an integer, like 25

$这个 - > DB->platform()

输出您正在运行的数据库平台(MySQL,MS SQL,Postgres等):

echo $this->db->platform();

$this - > DB->version()

输出正在运行的数据库版本:

echo $this->db->version();

使查询更容易

$this - > DB-> insert_string()

该函数简化了写入数据库插入的过程。它返回格式正确的SQL插入字符串。例子:

$data = array('name' => $name, 'email' => $email, 'url' => $url);$str = $this->db->insert_string('table_name', $data);

第一个参数是表名,第二个参数是要插入的数据的关联数组。上面的例子产生了:

INSERT INTO table_name (name, email, url) VALUES ('Rick', '[email protected]', 'example.com')

值会自动转义,从而产生更安全的查询。

$this - > DB-> update_string()

该函数简化了编写数据库更新的过程。它返回格式正确的SQL更新字符串。例子:

$data = array('name' => $name, 'email' => $email, 'url' => $url); $where = "author_id = 1 AND status = 'active'"; $str = $this->db->update_string('table_name', $data, $where);

第一个参数是表名,第二个参数是要更新的数据的关联数组,第三个参数是“WHERE”子句。上面的例子产生了:

UPDATE table_name SET name = 'Rick', email = '[email protected]', url = 'example.com' WHERE author_id = 1 AND status = 'active'

值会自动转义,从而产生更安全的查询。

이전 기사: 다음 기사: