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 16:49:36 +0000

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

Log:
Revert to query instead of multi_query. We can't wait multi_query finish to start anothers DB query...

Changed paths:
    U   web/doc-editor/trunk/php/DBConnection.php
    U   web/doc-editor/trunk/php/RepositoryManager.php
svn-diffs-291386.txt (text/x-diff, 8.7 KB)
Modified: web/doc-editor/trunk/php/DBConnection.php
===================================================================
--- web/doc-editor/trunk/php/DBConnection.php	2009-11-28 16:00:01 UTC (rev 291385)
+++ web/doc-editor/trunk/php/DBConnection.php	2009-11-28 16:49:36 UTC (rev 291386)
@@ -36,7 +36,7 @@
     }

     public function query($s)
-    {
+    {
         $r = $this->conn->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 16:00:01 UTC (rev 291385)
+++ web/doc-editor/trunk/php/RepositoryManager.php	2009-11-28 16:49:36 UTC (rev 291386)
@@ -57,12 +57,10 @@
      */
     public function cleanUp()
     {
-        // We cleanUp the database before update vcs and apply again all tools
-        $query = '';
+        // We cleanUp the database before update vcs and apply again all tools
         foreach (array('files', 'translators', 'errorfiles') as $table) {
-            $query .= "TRUNCATE TABLE $table; ";
-        }
-        DBConnection::getInstance()->multi_query($query);
+            DBConnection::getInstance()->query("TRUNCATE TABLE $table");
+        }
     }

     /**
@@ -164,19 +162,17 @@
      */
     public function delPendingCommit($files)
     {
-        $query = '';

         for ($i = 0; $i < count($files); $i++) {
-            $query .= sprintf('DELETE FROM `pendingCommit`
+            $query = 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()->multi_query($query);
+            );
+            DBConnection::getInstance()->query($query);
+        }
     }

     /**
@@ -539,7 +535,6 @@
      */
     public function updateTranslatorInfo()
     {
-        $query = '';

         foreach ($this->availableLang as $lang) {

@@ -577,22 +572,22 @@

                         $person = array_merge($default, $person);

-                        $query .= sprintf(
+                        $query = sprintf(
                             'INSERT INTO `translators` (`lang`, `nick`, `name`, `mail`, `vcs`, `editor`)
-                             VALUES ("%s", "%s", "%s", "%s", "%s", "%s"); ',
+                             VALUES ("%s", "%s", "%s", "%s", "%s", "%s")',
                             $lang,
                             DBConnection::getInstance()->real_escape_string($person['nick']),
                             DBConnection::getInstance()->real_escape_string($name),
                             DBConnection::getInstance()->real_escape_string($person['email']),
                             DBConnection::getInstance()->real_escape_string($person['vcs']),
                             DBConnection::getInstance()->real_escape_string($person['editor'])
-                        );
+                        );
+                        DBConnection::getInstance()->query($query);

                     }
                 }
             }
-        }
-        DBConnection::getInstance()->multi_query($query);
+        }
     }

     /**
@@ -643,8 +638,7 @@
         if ($dh = @opendir(DOC_EDITOR_VCS_PATH.$lang.$path)) {

             $dirs  = array();
-            $files = array();
-            $query = '';
+            $files = array();

             while (($name = readdir($dh)) !== false) {
                 $file = new File($lang, $path, $name);
@@ -665,15 +659,14 @@
                 $lang_file = DOC_EDITOR_VCS_PATH .$lang .$f->path .$f->name;

                 if (!@is_file($en_file)) {
-                    $query .= sprintf(
+                    $query = sprintf(
                         'INSERT INTO `files` (`lang`, `path`, `name`, `status`)
-                         VALUES ("%s", "%s", "%s", "%s"); ',
+                         VALUES ("%s", "%s", "%s", "%s")',
                         $lang, $f->path, $f->name, 'NotInEN'
-                    );
+                    );
+                    DBConnection::getInstance()->query($query);
                 }
             }
-
-            DBConnection::getInstance()->multi_query($query);

             foreach ($dirs as $d) {
                 $this->doUpdateNotInEN($d->path.$d->name.'/', $lang);
@@ -693,8 +686,7 @@
         if ($dh = @opendir(DOC_EDITOR_VCS_PATH.'en'.$path)) {

             $dirs  = array();
-            $files = array();
-            $query = '';
+            $files = array();

             while (($name = readdir($dh)) !== false) {

@@ -727,9 +719,9 @@
                 $ToolsCheckDocResult = $check_doc->checkDoc($infoEN['content'], $f->path);

                 // Sql insert.
-                $query .= sprintf(
+                $query = sprintf(
                     'INSERT INTO `files` (`lang`, `xmlid`, `path`, `name`, `revision`, `size`, `mdate`, `maintainer`, `status`, `check_oldstyle`,  `check_undoc`, `check_roleerror`, `check_badorder`, `check_noseealso`, `check_noreturnvalues`, `check_noparameters`, `check_noexamples`, `check_noerrors`)
-                        VALUES ("%s", "%s", "%s", "%s", "%s", %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s);',
+                        VALUES ("%s", "%s", "%s", "%s", "%s", %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)',
                     'en', $xmlid, $f->path, $f->name, $en_revision, $en_size, $en_date, 'NULL', 'NULL',
                     $ToolsCheckDocResult['check_oldstyle'],
                     $ToolsCheckDocResult['check_undoc'],
@@ -740,7 +732,8 @@
                     $ToolsCheckDocResult['check_noparameters'],
                     $ToolsCheckDocResult['check_noexamples'],
                     $ToolsCheckDocResult['check_noerrors']
-                );
+                );
+                DBConnection::getInstance()->query($query);

                 foreach($this->availableLang as $lang) {

@@ -762,14 +755,15 @@
                         $xmlid      = ($infoLANG['xmlid']      == 'NULL') ? 'NULL' : $infoLANG['xmlid'];
                         $reviewed   = ($infoLANG['reviewed']   == 'NULL') ? 'NULL' : $infoLANG['reviewed'];

-                        $query .= sprintf(
+                        $query = sprintf(
                             'INSERT INTO `files` (`lang`, `xmlid`, `path`, `name`, `revision`, `en_revision`, `reviewed`, `size`, `size_diff`, `mdate`, `mdate_diff`, `maintainer`, `status`)
-                                VALUES ("%s", "%s", "%s", "%s", "%s", "%s", "%s", %s, %s, %s, %s, "%s", "%s"); ',
+                                VALUES ("%s", "%s", "%s", "%s", "%s", "%s", "%s", %s, %s, %s, %s, "%s", "%s")',
                             $lang, $xmlid, $lang_file->path, $lang_file->name,
                             $revision, $en_revision, $reviewed,
                             $size, $size_diff, $date, $date_diff,
                             $maintainer, $status
                         );
+                        DBConnection::getInstance()->query($query);

                         // Check for error in this file ONLY if this file is uptodate
                         if ($revision == $en_revision ) {
@@ -782,16 +776,15 @@
                             $error->saveError();
                         }
                     } else {
-                        $query .= sprintf(
+                        $query = sprintf(
                             'INSERT INTO `files` (`lang`, `path`, `name`)
-                                VALUES ("%s", "%s", "%s"); ',
+                                VALUES ("%s", "%s", "%s")',
                             $lang, $lang_file->path, $lang_file->name
-                        );
+                        );
+                        DBConnection::getInstance()->query($query);
                     }
                 }
             }
-
-            DBConnection::getInstance()->multi_query($query);

             foreach ($dirs as $d) {
                 $this->applyRevCheck($d->path.$d->name.'/');
@@ -808,18 +801,17 @@
      */
     public function delFiles($files)
     {
-        $query = '';

         for ($i = 0; $i < count($files); $i++) {
-            $query .= sprintf('DELETE FROM files
+            $query = sprintf('DELETE FROM files
                 WHERE
                     `lang` = "%s" AND
                     `path` = "%s" AND
-                    `name` = "%s"; ',
+                    `name` = "%s"',
                 $files[$i]->lang, $files[$i]->path, $files[$i]->name
-            );
-        }
-        DBConnection::getInstance()->multi_query($query);
+            );
+            DBConnection::getInstance()->query($query);
+        }
     }

 }
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.