php sqlite3函数教程,PHP SQlite 函数库详解_PHP教程

PHP SQlite数据库对于拥有相当经验的PHP程序员来说是不会陌生的,但是要想完全掌握PHP SQlite数据库的相关函数的应用也不是一件易事。下面我们就为大家总结了一些PHP SQlite数据库的相关函数。

PHP SQlite数据库之sqlite_array_query —— 发送一条 SQL 查询,并返回一个数组。

sqlite_busy_timeout ——

设置超时时间(busy timeout duration),或者频繁的用户失去权限(disable busy handlers)。

sqlite_changes ——

返回被最新的SQL 查询(changed by the most recent SQL statement)改变的行数。

sqlite_close ——

关闭一个打开的SQLite数据库。

sqlite_column ——

在当前的行中取得一列(a column from the current row of a result set)。

sqlite_create_aggregate ——

Register an aggregating UDF for use in SQL statements。

sqlite_create_function ——

Registers a "regular" User Defined Function for use in SQL statements。

sqlite_current ——

在返回的数组中取得当前的行(the current row from a result set as an array)。

sqlite_error_string ——

返回错误代码的原始描述(the textual description of an error code)。

sqlite_escape_string ——

释放一个用于查询的字符串(Escapes a string for use as a query parameter)。

sqlite_fetch_array ——

取得下一行并设置成一个数组(the next row from a result set as an array)。

sqlite_fetch_single ——

取得第一列并设置成一个字符串(Fetches the first column of a result set as a string)。

sqlite_fetch_string ——

sqlite_fetch_single()的别名。

sqlite_field_name ——

取得结果中指定字段的字段名。

sqlite_has_more ——

返回是否有更多可用的行(whether or not more rows are available)。

sqlite_last_error ——

返回数据库的最新的错误代码(the error code of the last error for a database)。

sqlite_last_insert_rowid ——

返回最新插入的行的行号(the most recently inserted row)。

sqlite_libencoding ——

返回SQLite库(SQLite library)的编码(encoding)。

PHP SQlite数据库之sqlite_libversion ——

返回SQLite库(SQLite library)的版本。

sqlite_next ——

返回下一行的行号。

sqlite_num_fields ——

取得结果集中字段的数目。

sqlite_num_rows ——

取得结果集中行的数目。

sqlite_open ——

打开一个SQLite数据库。如果文件不存在则尝试创建之。

sqlite_popen ——

用永久连接的方式打开一个SQLite数据库。如果文件不存在则尝试创建之。

sqlite_query ——

发送一条 SQL 查询,并返回一个结果句柄(a result handle)。

sqlite_rewind ——

倒回第一行(Seek to the first row number)。

sqlite_seek ——

在缓存结果中查找特定的行号(Seek to a particular row number of a buffered result set)。

sqlite_udf_decode_binary ——

Decode binary data passed as parameters to an UDF。

sqlite_udf_encode_binary ——

Encode binary data before returning it from an UDF。

PHP SQlite数据库之sqlite_unbuffered_query ——

发送一条 SQL 查询,并不获取和缓存结果的行。

http://www.bkjia.com/PHPjc/486426.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/486426.htmlTechArticlePHP SQlite数据库对于拥有相当经验的PHP程序员来说是不会陌生的,但是要想完全掌握PHP SQlite数据库的相关函数的应用也不是一件易事。下面...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
sqlite3_exec()函数SQLite库中最常用的函数之一,它用于执行SQL语句并调用回调函数处理结果。下面是sqlite3_exec()函数的详细解释: 1. 头文件和函数原型 ```c #include "sqlite3.h" int sqlite3_exec(sqlite3*, const char *sql, int (*callback)(void*para,int argc,char**argv,char**argv_name), void *para,char **errmsg) ``` 2. 参数说明 - sqlite3*:SQLite数据库连接对象。 - sql:要执行的SQL语句。 - callback:回调函数,用于处理SQL语句执行结果。 - para:传递给回调函数的参数。 - errmsg:如果执行SQL语句出错,将错误信息存储在此处。 3. 回调函数 回调函数sqlite3_exec()函数的一个重要参数,用于处理SQL语句执行结果。回调函数的原型如下: ```c int callback(void *para, int argc, char **argv, char **argv_name); ``` - para:sqlite3_exec()函数中传递给回调函数的参数。 - argc:结果集中的列数。 - argv:结果集中的一行数据。 - argv_name:结果集中每一列的列名。 回调函数返回一个整数值,用于告诉sqlite3_exec()函数是否继续执行SQL语句。如果回调函数返回0,则继续执行SQL语句;如果返回非0值,则停止执行SQL语句。 4. 示例 下面是一个使用sqlite3_exec()函数执行SQL语句的示例: ```c #include <stdio.h> #include <stdlib.h> #include <sqlite3.h> int callback(void *para, int argc, char **argv, char **argv_name) { int i; for (i = 0; i < argc; i++) { printf("%s = %s\n", argv_name[i], argv[i] ? argv[i] : "NULL"); } printf("\n"); return 0; } int main(int argc, char **argv) { sqlite3 *db; char *errmsg = 0; int ret; ret = sqlite3_open("test.db", &db); if (ret != SQLITE_OK) { fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db)); sqlite3_close(db); return 1; } ret = sqlite3_exec(db, "SELECT * FROM test", callback, 0, &errmsg); if (ret != SQLITE_OK) { fprintf(stderr, "SQL error: %s\n", errmsg); sqlite3_free(errmsg); } sqlite3_close(db); return 0; } ``` 以上代码打开了一个名为test.db的SQLite数据库,并执行了一条SELECT语句,将结果集传递给回调函数callback()处理。在回调函数中,我们遍历了结果集中的每一行数据,并输出了每一列的列名和值。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值