function executeemulatequery($stmt, $data = false) 返回一个实际的查询字符串,供仿真prepare,execute的时候使用,内部函数。如果出错,则返回db_error对象
function executemultiple( $stmt, &$data ) 在同一个查询句柄上执行多个查询。$data必需是一个从0开始的数组,这个函数将 依次使用数组中的每一行数据来调用execute。这个函数一般用于参数查询。你可执行一次 查询的编译,然后将不同的参数值放入$data数组,然后就可一次同时执行查询了。需要注意,如果中间某个查询出错,剩余的查询不会继续进行而是返回错误。
function modifyquery($query) 内部函数,用于后端数据库修正查询,后端数据库实现这个函数,然后返回进行优化和修正后查询串。例子:这是db_mysql的实现, <?php function modifyquery($query) { if ($this->options['optimize'] == 'portability') { // "delete from table" gives 0 affected rows in mysql. // this little hack lets you know how many rows were deleted. if (preg_match('/^/s*delete/s+from/s+(/s+)/s*$/i', $query)) { $query = preg_replace('/^/s*delete/s+from/s+(/s+)/s*$/', 'delete from /1 where 1=1', $query); } } return $query; } ?>
function &query($query) 执行一个查询,查询成功,如果是有结果集的查询,则回一个db_result对象,如果没有结果集的查询则返回db_ok。
出错则返回db_error对象。
function &getone($query, $params = array()) 执行查询,并返回结果集中第一行第一列的数据。$params是参数值,如果后端数据库支持,将调用prepare/execute来使用这些参数。
db的开发状态 db目前仍在不断地开发当中,在db/下面有一个文件status,它描述了db类的功能和各个后端数据库的实现情况,下面是php4.0.6这个发布中的开发情况: "x" - 已经实现,但尚未测试implemented, but without tests "t" - 已经实现,但是一个或多个测试没有通过implemented, but one or more tests fail "t" - 实现并通过全部测试implemented, passing all tests "e" - 仿真实现,没有测试emulated, without tests "e" - 仿真实现,通过全部测试emulated, passing all tests "n" - 返回 "not capable",没有这个能力提供该项功能 "-" - 没有实现 fbsql ifx mssql oci8 pgsql feature | ibase | msql | mysql | odbc | sybase simplequery x x x x x t t x t x numcols x x x x x t t x t x numrows x n n x x t e n t n errornative x n x n n t x x t n prepare/execute e x e e e e t e e e sequences e n n n n e t n t n affectedrows x n x n n t t n t n fetch modes x x x x x t t x t x fetch absolute rows x n x x x x n x x x transactions x x n n n n x x x n auto-commit x x n n n n x x x n error mapping x - e - - t t x e - tableinfo x n n n n t n n n n