Update of /cvsroot/php-blog/serendipity/include/db
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16565
Modified Files:
mysql.inc.php mysqli.inc.php postgres.inc.php sqlite.inc.php
Log Message:
mysql_affected_rows returns number of rows MODIFIED, not numebr of rows MATCHED
on an UPDATE statement.
serendipity_db_updated_rows returns the number of rows MATCHED.
For postgres and Sqllite, there is no mention of a problem with UPDATE statements,
but this needs to be examined.
Index: mysqli.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/include/db/mysqli.inc.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- mysqli.inc.php 30 Nov 2004 07:50:42 -0000 1.5
+++ mysqli.inc.php 7 Jan 2005 19:06:38 -0000 1.6
@@ -72,6 +72,18 @@
return mysqli_affected_rows($serendipity['dbConn']);
}
+function serendipity_db_updated_rows() {
+ global $serendipity;
+
+ preg_match(
+ "/^[^0-9]+([0-9]+)[^0-9]+([0-9]+)[^0-9]+([0-9]+)[^0-9]+$/",
+ mysqli_info(),
+ $arr);
+ // mysqli_affected_rows returns 0 if rows were matched but not changed.
+ // mysqli_info returns rows matched
+ return $arr[1];
+}
+
function serendipity_db_escape_string($string) {
global $serendipity;
return mysqli_escape_string($serendipity['dbConn'], $string);
Index: mysql.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/include/db/mysql.inc.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- mysql.inc.php 30 Nov 2004 07:50:42 -0000 1.5
+++ mysql.inc.php 7 Jan 2005 19:06:30 -0000 1.6
@@ -78,6 +78,18 @@
return mysql_affected_rows($serendipity['dbConn']);
}
+function serendipity_db_updated_rows() {
+ global $serendipity;
+
+ preg_match(
+ "/^[^0-9]+([0-9]+)[^0-9]+([0-9]+)[^0-9]+([0-9]+)[^0-9]+$/",
+ mysql_info(),
+ $arr);
+ // mysql_affected_rows returns 0 if rows were matched but not changed.
+ // mysql_info returns rows matched
+ return $arr[1];
+}
+
function serendipity_db_escape_string($string) {
return mysql_escape_string($string);
}
Index: postgres.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/include/db/postgres.inc.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- postgres.inc.php 30 Nov 2004 07:50:42 -0000 1.5
+++ postgres.inc.php 7 Jan 2005 19:06:39 -0000 1.6
@@ -45,6 +45,13 @@
return pg_affected_rows($serendipity['dbLastResult']);
}
+function serendipity_db_updated_rows() {
+ global $serendipity;
+ // it is unknown whether pg_affected_rows returns number of rows
+ // UPDATED or MATCHED on an UPDATE statement.
+ return pg_affected_rows($serendipity['dbLastResult']);
+}
+
function serendipity_db_insert_id($table = '', $id = '') {
global $serendipity;
if (empty($table) || empty($id)) {
Index: sqlite.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/include/db/sqlite.inc.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- sqlite.inc.php 30 Nov 2004 07:50:42 -0000 1.5
+++ sqlite.inc.php 7 Jan 2005 19:06:39 -0000 1.6
@@ -40,6 +40,13 @@
return sqlite_changes($serendipity['dbConn']);
}
+function serendipity_db_updated_rows()
+{
+ global $serendipity;
+ // It is unknown whether sqllite returns rows MATCHED or rows UPDATED
+ return sqlite_changes($serendipity['dbConn']);
+}
+
function serendipity_db_insert_id()
{
global $serendipity;
|