Update of /cvsroot/php-blog/serendipity/include/db
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21879
Modified Files:
mysql.inc.php mysqli.inc.php postgres.inc.php sqlite.inc.php
Log Message:
we need both _updated_ for changed rows, and _matched_ for
matched but not changed rows.
Index: mysqli.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/include/db/mysqli.inc.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- mysqli.inc.php 7 Jan 2005 19:06:38 -0000 1.6
+++ mysqli.inc.php 7 Jan 2005 19:30:55 -0000 1.7
@@ -76,7 +76,7 @@
global $serendipity;
preg_match(
- "/^[^0-9]+([0-9]+)[^0-9]+([0-9]+)[^0-9]+([0-9]+)[^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.
@@ -84,6 +84,18 @@
return $arr[1];
}
+function serendipity_db_matched_rows() {
+ global $serendipity;
+
+ preg_match(
+ "/^[^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[0];
+}
+
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.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- mysql.inc.php 7 Jan 2005 19:06:30 -0000 1.6
+++ mysql.inc.php 7 Jan 2005 19:30:55 -0000 1.7
@@ -82,11 +82,23 @@
global $serendipity;
preg_match(
- "/^[^0-9]+([0-9]+)[^0-9]+([0-9]+)[^0-9]+([0-9]+)[^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
+ // mysql_info returns rows matched AND rows changed
+ return $arr[2];
+}
+
+function serendipity_db_matched_rows() {
+ global $serendipity;
+
+ preg_match(
+ "/^[^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 AND rows changed
return $arr[1];
}
Index: postgres.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/include/db/postgres.inc.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- postgres.inc.php 7 Jan 2005 19:06:39 -0000 1.6
+++ postgres.inc.php 7 Jan 2005 19:30:55 -0000 1.7
@@ -52,6 +52,13 @@
return pg_affected_rows($serendipity['dbLastResult']);
}
+function serendipity_db_matched_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.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- sqlite.inc.php 7 Jan 2005 19:06:39 -0000 1.6
+++ sqlite.inc.php 7 Jan 2005 19:30:55 -0000 1.7
@@ -46,6 +46,13 @@
// It is unknown whether sqllite returns rows MATCHED or rows UPDATED
return sqlite_changes($serendipity['dbConn']);
}
+
+function serendipity_db_matched_rows()
+{
+ global $serendipity;
+ // It is unknown whether sqllite returns rows MATCHED or rows UPDATED
+ return sqlite_changes($serendipity['dbConn']);
+}
function serendipity_db_insert_id()
{
|