Physikerwelt has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/110895

Change subject: switch back to ibm driver (pdo_ibm->ibm_db2)
......................................................................

switch back to ibm driver (pdo_ibm->ibm_db2)

* db2pdo seems to be not very well supported event though though
  the API of PDO is somhow nicer

Change-Id: Ib198630e3a0b558407891b96aaa4f01481200c35
---
M maintenance/ExportMathTable.php
1 file changed, 15 insertions(+), 30 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MathSearch 
refs/changes/95/110895/1

diff --git a/maintenance/ExportMathTable.php b/maintenance/ExportMathTable.php
index cfb4ec4..7f10d6f 100644
--- a/maintenance/ExportMathTable.php
+++ b/maintenance/ExportMathTable.php
@@ -28,15 +28,13 @@
  *
  */
 class ExportMathTable extends IndexBase {
-       private $db2Pass;
        private $statment;
-       private $dbh;
+       private $conn;
        private $time;
 
        public function __construct() {
                parent::__construct();
                $this->mDescription = 'Exports a db2 compatible math index 
table.';
-               $this->addArg( 'passw', "If set, the data is directly imported 
to db2", false );
                $this->addArg( 'truncate', "If true, db2 math table is deleted 
before import", false );
        }
 
@@ -51,24 +49,17 @@
                $out .= ','. $row->mathindex_page_id .'';
                $out .= ','. $row->mathindex_anchor.'';
                $out .= ',"'.str_replace(array('"',"\n"),array('"',' '), 
$mo->getMathml()).'"';
-               if( $this->db2Pass ) {
-                       try { 
-                               
$this->statment->execute(array($mo->getMd5(),$mo->getTex(),$row->mathindex_page_id,$row->mathindex_anchor,$mo->getMathml()));
-                       } catch (Exception $e) {
-                               echo($e->getMessage());
-                       }
+               $res = db2_execute($this->statment, 
array($mo->getMd5(),$mo->getTex(),$row->mathindex_page_id,$row->mathindex_anchor,$mo->getMathml()));
+               if ( $res ){
+                       echo db2_stmt_errormsg();
                }
                return $out."\n";
        }
 
        protected function wFile( $fn, $min, $inc ) {
-       if( $this->db2Pass ) {
-               try{
-               $this->dbh->commit();
-               } catch (Exception $e) {
-                         echo($e->getMessage());
-               }
-               $this->dbh->beginTransaction();
+       $res = db2_commit($this->conn);
+       if ( $res ){
+               echo db2_stmt_errormsg();
        }
        $delta = microtime(true) - $this->time ;
        $this->time = microtime(true);
@@ -77,23 +68,17 @@
 }
 
        public function execute() {
+               global $wgMathSearchDB2ConnStr;
                $this->time = microtime(true);
-               $this->db2Pass = $this->getOption( 'passw',false );
-               if ( $this->db2Pass ){
-                       try {
-                               $this->dbh = new PDO("ibm:MATH", "db2inst1", 
$this->db2Pass, array(
-                                       PDO::ATTR_PERSISTENT => TRUE,
-                                       PDO::ATTR_ERRMODE => 
PDO::ERRMODE_EXCEPTION)
-                               );
-                       } catch (Exception $e) {
-                         echo($e->getMessage());
-                       }
+               $this->conn = db2_connect($wgMathSearchDB2ConnStr, '', '');
+               if ( $this->conn ){
                        if ( $this->getOption('truncate' , false ) ){
-                                $this->dbh->query('TRUNCATE TABLE 
"wiki"."math" IMMEDIATE');
+                               db2_exec($this->conn,'DROP TABLE "math"');
+                               db2_exec( $this->conn , 'CREATE TABLE "math" 
("math_md5" CHAR(32), "math_tex" VARCHAR(1000), "mathindex_pageid" INTEGER, 
"mathindex_anchord" INTEGER, "math_mathml" XML)');
+                               
                        }
-                       $this->dbh->beginTransaction();
-                       $this->statment = $this->dbh->prepare('insert into 
"wiki"."math" ("math_md5", "math_tex", "mathindex_pageid", "mathindex_anchord", 
"math_mathml") values(?, ?, ?, ?, ?)');
-                       
+                       $this->statment = db2_prepare( $this->conn ,'insert 
into "math" ("math_md5", "math_tex", "mathindex_pageid", "mathindex_anchord", 
"math_mathml") values(?, ?, ?, ?, ?)');
+                       //db2_autocommit($this->conn , DB2_AUTOCOMMIT_OFF);
                }
                parent::execute();
        }

-- 
To view, visit https://gerrit.wikimedia.org/r/110895
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib198630e3a0b558407891b96aaa4f01481200c35
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MathSearch
Gerrit-Branch: master
Gerrit-Owner: Physikerwelt <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to