patch to add row count to pdo_firebird
[email protected] (Paul Reeves) Mon, 15 Nov 2010 08:24:13 +0100
| Newsgroups | php.pdo |
|---|---|
| Organization | IBPhoenix |
| Message-ID | <[email protected]> |
--Boundary-00=_dAO4Mw0/KhBG4Hx
Content-Type: Text/Plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
I've prepared a patch for firebird_statement.c
It just sets the row_count when rows are modified. The code itself is well
tested - I just lifted it from the equivalent ibase code.
I also added a line to update the row count when a row is fetched.
Paul
--
Paul Reeves
http://www.ibphoenix.com
Specialists in Firebird support
--Boundary-00=_dAO4Mw0/KhBG4Hx
Content-Type: text/x-patch;
charset="UTF-8";
name="php-5.3.3-pdo_firebird_statement_row_count.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="php-5.3.3-pdo_firebird_statement_row_count.patch"
--- ext/pdo_firebird/firebird_statement.c.orig 2010-01-03 10:23:27.000000000 +0100
+++ ext/pdo_firebird/firebird_statement.c 2010-11-11 10:28:08.000000000 +0100
@@ -103,6 +103,38 @@
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. */
+ unsigned long affected_rows = 0;
+ stmt->row_count = affected_rows;
+ switch (S->statement_type) {
+ static char info_count[] = {isc_info_sql_records};
+ char result[64];
+
+ 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:
+ ;
+ } //switch
+
/* 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;
--Boundary-00=_dAO4Mw0/KhBG4Hx--