svn: /web/doc-editor/trunk/php/ DBConnection.php RepositoryManager.php

[email protected] (Yannick Torres)
Newsgroups php.doc.web
Message-ID <[email protected]>
yannick                                  Sat, 28 Nov 2009 10:44:34 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=291375

Log:
Add multi_query support to DBManager & use it into delPendingCommit's method

Changed paths:
    U   web/doc-editor/trunk/php/DBConnection.php
    U   web/doc-editor/trunk/php/RepositoryManager.php

Modified: web/doc-editor/trunk/php/DBConnection.php
===================================================================
--- web/doc-editor/trunk/php/DBConnection.php	2009-11-28 08:06:16 UTC (rev 291374)
+++ web/doc-editor/trunk/php/DBConnection.php	2009-11-28 10:44:34 UTC (rev 291375)
@@ -50,6 +50,12 @@
     {
         return $this->conn->real_escape_string($escape_str);
     }
+
+    public function multi_query($s)
+    {
+        $r = $this->conn->multi_query($s) or die('Error: '.$this->conn->error.'|'.$s);
+        return $r;
+    }
 }

 ?>

Modified: web/doc-editor/trunk/php/RepositoryManager.php
===================================================================
--- web/doc-editor/trunk/php/RepositoryManager.php	2009-11-28 08:06:16 UTC (rev 291374)
+++ web/doc-editor/trunk/php/RepositoryManager.php	2009-11-28 10:44:34 UTC (rev 291375)
@@ -161,17 +161,21 @@
      * @param $files An array of File instances.
      */
     public function delPendingCommit($files)
-    {
+    {
+        // Initiate the $s var to store the multi_query
+        $s = '';
+
         for ($i = 0; $i < count($files); $i++) {
-            $s = sprintf('DELETE FROM `pendingCommit`
+            $s .= sprintf('DELETE FROM `pendingCommit`
                 WHERE
                     `lang` = "%s" AND
                     `path` = "%s" AND
-                    `name` = "%s"',
+                    `name` = "%s"; ',
                 $files[$i]->lang, $files[$i]->path, $files[$i]->name
             );
-            DBConnection::getInstance()->query($s);
-        }
+        }
+
+        DBConnection::getInstance()->multi_query($s);
     }

     /**
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.