summaryrefslogtreecommitdiff
path: root/ext/pdo_firebird
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-02-16 10:13:02 +0100
committerOndřej Surý <ondrej@sury.org>2011-02-16 10:13:02 +0100
commitfd5a0b31640419ca63d1ddeaffd6d3cf2a741814 (patch)
treebfd17d84c5181d7b98d7d66f56573f4fc897e31c /ext/pdo_firebird
parent01fcdff3849c3691d9aaeaab735846ab6d8895ca (diff)
downloadphp-fd5a0b31640419ca63d1ddeaffd6d3cf2a741814.tar.gz
Imported Upstream version 5.3.5upstream/5.3.5
Diffstat (limited to 'ext/pdo_firebird')
-rw-r--r--ext/pdo_firebird/config.w326
-rw-r--r--ext/pdo_firebird/firebird_driver.c8
-rw-r--r--ext/pdo_firebird/firebird_statement.c35
-rw-r--r--ext/pdo_firebird/tests/rowCount.phpt48
4 files changed, 92 insertions, 5 deletions
diff --git a/ext/pdo_firebird/config.w32 b/ext/pdo_firebird/config.w32
index 82ddf062f..8234e48b2 100644
--- a/ext/pdo_firebird/config.w32
+++ b/ext/pdo_firebird/config.w32
@@ -1,4 +1,4 @@
-// $Id: config.w32 212867 2006-05-11 21:43:59Z edink $
+// $Id: config.w32 305343 2010-11-14 22:40:30Z pajoye $
// vim:ft=javascript
ARG_WITH("pdo-firebird", "Firebird support for PDO", "no");
@@ -7,7 +7,9 @@ if (PHP_PDO_FIREBIRD != "no") {
if ((CHECK_LIB("fbclient_ms.lib", "pdo_firebird", PHP_PHP_BUILD + "\\interbase\\lib_ms;" + PHP_PDO_FIREBIRD)
|| CHECK_LIB("gds32_ms.lib", "pdo_firebird", PHP_PHP_BUILD + "\\interbase\\lib_ms;" + PHP_PDO_FIREBIRD)
- ) && CHECK_HEADER_ADD_INCLUDE("ibase.h", "CFLAGS_PDO_FIREBIRD", PHP_PHP_BUILD + "\\interbase\\include;" + PHP_PDO_FIREBIRD)) {
+ ) && CHECK_HEADER_ADD_INCLUDE("ibase.h", "CFLAGS_PDO_FIREBIRD",
+ PHP_PHP_BUILD + "\\include\\interbase;" + PHP_PHP_BUILD + "\\interbase\\include;" + PHP_PDO_FIREBIRD)
+ ) {
EXTENSION("pdo_firebird", "pdo_firebird.c firebird_driver.c firebird_statement.c");
} else {
diff --git a/ext/pdo_firebird/firebird_driver.c b/ext/pdo_firebird/firebird_driver.c
index db6bca16d..b72bb9d8c 100644
--- a/ext/pdo_firebird/firebird_driver.c
+++ b/ext/pdo_firebird/firebird_driver.c
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: firebird_driver.c 293447 2010-01-12 12:46:54Z iliaa $ */
+/* $Id: firebird_driver.c 305416 2010-11-16 21:02:14Z felipe $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -547,7 +547,7 @@ static int firebird_handle_get_attribute(pdo_dbh_t *dbh, long attr, zval *val TS
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
switch (attr) {
- char tmp[200];
+ char tmp[512];
case PDO_ATTR_AUTOCOMMIT:
ZVAL_LONG(val,dbh->auto_commit);
@@ -590,6 +590,10 @@ static int firebird_handle_get_attribute(pdo_dbh_t *dbh, long attr, zval *val TS
ZVAL_STRING(val,tmp,1);
return 1;
}
+
+ case PDO_ATTR_FETCH_TABLE_NAMES:
+ ZVAL_BOOL(val, H->fetch_table_names);
+ return 1;
}
return 0;
}
diff --git a/ext/pdo_firebird/firebird_statement.c b/ext/pdo_firebird/firebird_statement.c
index 8c6bb83c3..aea7bd559 100644
--- a/ext/pdo_firebird/firebird_statement.c
+++ b/ext/pdo_firebird/firebird_statement.c
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: firebird_statement.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: firebird_statement.c 305476 2010-11-18 01:24:00Z felipe $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -90,6 +90,9 @@ static int firebird_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
{
pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;
pdo_firebird_db_handle *H = S->H;
+ unsigned long affected_rows = 0;
+ static char info_count[] = {isc_info_sql_records};
+ char result[64];
do {
/* named or open cursors should be closed first */
@@ -103,6 +106,35 @@ static int firebird_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
break;
}
+ /* Determine how many rows have changed. In this case we are
+ * only interested in rows changed, not rows retrieved. That
+ * should be handled by the client when fetching. */
+ stmt->row_count = affected_rows;
+
+ switch (S->statement_type) {
+ case isc_info_sql_stmt_insert:
+ case isc_info_sql_stmt_update:
+ case isc_info_sql_stmt_delete:
+ case isc_info_sql_stmt_exec_procedure:
+ if (isc_dsql_sql_info(H->isc_status, &S->stmt, sizeof ( info_count),
+ info_count, sizeof(result), result)) {
+ break;
+ }
+ if (result[0] == isc_info_sql_records) {
+ unsigned i = 3, result_size = isc_vax_integer(&result[1], 2);
+ while (result[i] != isc_info_end && i < result_size) {
+ short len = (short) isc_vax_integer(&result[i + 1], 2);
+ if (result[i] != isc_info_req_select_count) {
+ affected_rows += isc_vax_integer(&result[i + 3], len);
+ }
+ i += len + 3;
+ }
+ stmt->row_count = affected_rows;
+ }
+ default:
+ ;
+ }
+
/* commit? */
if (stmt->dbh->auto_commit && isc_commit_retaining(H->isc_status, &H->tr)) {
break;
@@ -142,6 +174,7 @@ static int firebird_stmt_fetch(pdo_stmt_t *stmt, /* {{{ */
if (S->statement_type == isc_info_sql_stmt_exec_procedure) {
S->exhausted = 1;
}
+ stmt->row_count++;
return 1;
}
return 0;
diff --git a/ext/pdo_firebird/tests/rowCount.phpt b/ext/pdo_firebird/tests/rowCount.phpt
new file mode 100644
index 000000000..1cb09e1e9
--- /dev/null
+++ b/ext/pdo_firebird/tests/rowCount.phpt
@@ -0,0 +1,48 @@
+--TEST--
+PDO_Firebird: rowCount
+--SKIPIF--
+<?php extension_loaded("pdo_firebird") or die("skip"); ?>
+--FILE--
+<?php /* $Id: rowCount.phpt 305476 2010-11-18 01:24:00Z felipe $ */
+
+require("testdb.inc");
+
+$dbh = new PDO("firebird:dbname=$test_base",$user,$password) or die;
+
+@$dbh->exec('DROP TABLE testz');
+$dbh->exec('CREATE TABLE testz (A VARCHAR(10))');
+$dbh->exec("INSERT INTO testz VALUES ('A')");
+$dbh->exec("INSERT INTO testz VALUES ('A')");
+$dbh->exec("INSERT INTO testz VALUES ('B')");
+$dbh->commit();
+
+$query = "SELECT * FROM testz WHERE A = ?";
+
+$stmt = $dbh->prepare($query);
+$stmt->execute(array('A'));
+$rows = $stmt->fetch();
+$rows = $stmt->fetch();
+var_dump($stmt->fetch());
+var_dump($stmt->rowCount());
+
+$stmt = $dbh->prepare('UPDATE testZ SET A="A" WHERE A != ?');
+$stmt->execute(array('A'));
+var_dump($stmt->rowCount());
+$dbh->commit();
+
+$stmt = $dbh->prepare('DELETE FROM testz');
+$stmt->execute();
+var_dump($stmt->rowCount());
+
+$dbh->commit();
+
+$dbh->exec('DROP TABLE testz');
+
+unset($dbh);
+
+?>
+--EXPECT--
+bool(false)
+int(2)
+int(1)
+int(3)