svn: /php/php-src/ branches/PHP_5_3/NEWS branches/PHP_5_3/ext/pdo_firebird/firebird_statement.c branches/PHP_5_3/ext/pdo_firebird/tests/rowCount.phpt
trunk/ext/pdo_firebird/firebird_statement.c trunk/ext/pdo_firebird/tests/rowCount.phpt
| From: | Felipe Pena | Date: | Thu, 18 Nov 2010 01:24:00 +0000 |
| Subject: | svn: /php/php-src/ branches/PHP_5_3/NEWS branches/PHP_5_3/ext/pdo_firebird/firebird_statement.c branches/PHP_5_3/ext/pdo_firebird/tests/rowCount.phpt trunk/ext/pdo_firebird/firebird_statement.c trunk/ext/pdo_firebird/tests/rowCount.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-63880@lists.php.net to get a copy of this message | ||
felipe Thu, 18 Nov 2010 01:24:00 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=305476
Log:
- Fixed bug #53335 (pdo_firebird did not implement rowCount())
patch by: preeves at ibphoenix dot com
Bug: http://bugs.php.net/53335 (Open) pdo_firebird did not
implement rowCount()
Changed paths:
U php/php-src/branches/PHP_5_3/NEWS
U php/php-src/branches/PHP_5_3/ext/pdo_firebird/firebird_statement.c
A php/php-src/branches/PHP_5_3/ext/pdo_firebird/tests/rowCount.phpt
U php/php-src/trunk/ext/pdo_firebird/firebird_statement.c
A php/php-src/trunk/ext/pdo_firebird/tests/rowCount.phpt
Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS 2010-11-17 23:57:47 UTC (rev 305475)
+++ php/php-src/branches/PHP_5_3/NEWS 2010-11-18 01:24:00 UTC (rev 305476)
@@ -64,6 +64,8 @@
- Fixed the filter extension accepting IPv4 octets with a leading 0 as that
belongs to the unsupported "dotted octal" representation. (Gustavo)
+- Fixed bug #53335 (pdo_firebird did not implement rowCount()).
+ (preeves at ibphoenix dot com)
- Fixed bug #53323 (pdo_firebird getAttribute() crash).
(preeves at ibphoenix dot com)
- Fixed Bug #53319 (strip_tags() may strip '<br />' incorrectly). (Felipe)
Modified: php/php-src/branches/PHP_5_3/ext/pdo_firebird/firebird_statement.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/pdo_firebird/firebird_statement.c 2010-11-17 23:57:47 UTC (rev
305475)
+++ php/php-src/branches/PHP_5_3/ext/pdo_firebird/firebird_statement.c 2010-11-18 01:24:00 UTC (rev
305476)
@@ -90,6 +90,9 @@
{
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 @@
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 @@
if (S->statement_type == isc_info_sql_stmt_exec_procedure) {
S->exhausted = 1;
}
+ stmt->row_count++;
return 1;
}
return 0;
Added: php/php-src/branches/PHP_5_3/ext/pdo_firebird/tests/rowCount.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/pdo_firebird/tests/rowCount.phpt (rev
0)
+++ php/php-src/branches/PHP_5_3/ext/pdo_firebird/tests/rowCount.phpt 2010-11-18 01:24:00 UTC (rev
305476)
@@ -0,0 +1,48 @@
+--TEST--
+PDO_Firebird: rowCount
+--SKIPIF--
+<?php extension_loaded("pdo_firebird") or die("skip"); ?>
+--FILE--
+<?php /* $Id$ */
+
+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)
Property changes on: php/php-src/branches/PHP_5_3/ext/pdo_firebird/tests/rowCount.phpt
___________________________________________________________________
Added: svn:keywords
+ Id Rev Revision
Added: svn:eol-style
+ native
Modified: php/php-src/trunk/ext/pdo_firebird/firebird_statement.c
===================================================================
--- php/php-src/trunk/ext/pdo_firebird/firebird_statement.c 2010-11-17 23:57:47 UTC (rev 305475)
+++ php/php-src/trunk/ext/pdo_firebird/firebird_statement.c 2010-11-18 01:24:00 UTC (rev 305476)
@@ -90,6 +90,9 @@
{
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 @@
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 @@
if (S->statement_type == isc_info_sql_stmt_exec_procedure) {
S->exhausted = 1;
}
+ stmt->row_count++;
return 1;
}
return 0;
Added: php/php-src/trunk/ext/pdo_firebird/tests/rowCount.phpt
===================================================================
--- php/php-src/trunk/ext/pdo_firebird/tests/rowCount.phpt (rev 0)
+++ php/php-src/trunk/ext/pdo_firebird/tests/rowCount.phpt 2010-11-18 01:24:00 UTC (rev 305476)
@@ -0,0 +1,48 @@
+--TEST--
+PDO_Firebird: rowCount
+--SKIPIF--
+<?php extension_loaded("pdo_firebird") or die("skip"); ?>
+--FILE--
+<?php /* $Id$ */
+
+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)
Property changes on: php/php-src/trunk/ext/pdo_firebird/tests/rowCount.phpt
___________________________________________________________________
Added: svn:keywords
+ Id Rev Revision
Added: svn:eol-style
+ native