php sqlite execute,PHP sqlite_exec 用法 手册 | 示例代码

这篇博客探讨了在PHP中使用SQLite执行多行SQL命令时,如果某一行出现错误,函数会捕获错误并返回FALSE,但之前正确的命令仍会执行。尽管如此,changes()函数可能会报告0行被修改,即使有成功的命令已添加了数据到表中。示例代码展示了如何创建表、插入数据以及查询结果,并显示了在错误情况下数据的变更和获取情况。
摘要由CSDN通过智能技术生成

If you run a multiline SQL command (an INSERT, for example), and there is a SQL error in any of the lines, this function will recognize the error and return FALSE.  However, any correct commands before the one with the error will still execute.  Additionally, if you run changes() after such an incident, it will report that 0 rows have been changed, even though there were rows added to the table by the successful commands.

An example would be:

<?php // create new database (OO interface)$dbo= newSQLiteDatabase("db/database.sqlite");// create table foo$dbo->query("CREATE TABLE foo(id INTEGER PRIMARY KEY, name CHAR(255));");// insert sample data$ins_query="INSERT INTO foo (name) VALUES ('Ilia1');

INSERT INTO foo (name) VALUES('Ilia2');

INSECT INTO foo (name) VALUES('Ilia3');";$dbo->queryExec($ins_query);// get number of rows changed$changes=$dbo->changes();

echo"
Rows changed:$changes
";// Get and show inputted data$tableArray=$dbo->arrayQuery("SELECT * FROM foo;");

echo"Table Contentsn";

echo"

n";print_r($tableArray);

echo"n

";?>

The above code should show that 0 rows have been changed, but that there is new data in the table.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值