minor typo in comment
[lhc/web/wiklou.git] / includes / db / DatabaseIbm_db2.php
index 2e6f8c1..a2a2be0 100644 (file)
@@ -13,7 +13,7 @@
  * This represents a column in a DB2 database
  * @ingroup Database
  */
-class IBM_DB2Field {
+class IBM_DB2Field implements Field {
        private $name = '';
        private $tablename = '';
        private $type = '';
@@ -75,7 +75,7 @@ SQL;
         * Can column be null?
         * @return bool true or false
         */
-       function nullable() { return $this->nullable; }
+       function isNullable() { return $this->nullable; }
        /**
         * How much can you fit in the column per row?
         * @return int length
@@ -114,9 +114,8 @@ class DatabaseIbm_db2 extends DatabaseBase {
        protected $mPHPError = false;
 
        protected $mServer, $mUser, $mPassword, $mConn = null, $mDBname;
-       protected $mOut, $mOpened = false;
+       protected $mOpened = false;
 
-       protected $mFailFunction;
        protected $mTablePrefix;
        protected $mFlags;
        protected $mTrxLevel = 0;
@@ -257,24 +256,15 @@ class DatabaseIbm_db2 extends DatabaseBase {
         * @param $user String: username
         * @param $password String: password
         * @param $dbName String: database name on the server
-        * @param $failFunction Callback (optional)
         * @param $flags Integer: database behaviour flags (optional, unused)
         * @param $schema String
         */
-       public function DatabaseIbm_db2( $server = false, $user = false,
+       public function __construct( $server = false, $user = false,
                                                        $password = false,
-                                                       $dbName = false, $failFunction = false, $flags = 0,
+                                                       $dbName = false, $flags = 0,
                                                        $schema = self::USE_GLOBAL )
        {
-
-               global $wgOut, $wgDBmwschema;
-               # Can't get a reference if it hasn't been set yet
-               if ( !isset( $wgOut ) ) {
-                       $wgOut = null;
-               }
-               $this->mOut =& $wgOut;
-               $this->mFailFunction = $failFunction;
-               $this->mFlags = DBO_TRX | $flags;
+               global $wgDBmwschema;
 
                if ( $schema == self::USE_GLOBAL ) {
                        $this->mSchema = $wgDBmwschema;
@@ -290,7 +280,7 @@ class DatabaseIbm_db2 extends DatabaseBase {
                $this->setDB2Option( 'rowcount', 'DB2_ROWCOUNT_PREFETCH_ON',
                        self::STMT_OPTION );
 
-               $this->open( $server, $user, $password, $dbName );
+               parent::__construct( $server, $user, $password, $dbName, $flags );
        }
 
        /**
@@ -431,24 +421,6 @@ ERROR;
                }
        }
 
-       /**
-        * Returns a fresh instance of this class
-        *
-        * @param $server String: hostname of database server
-        * @param $user String: username
-        * @param $password String
-        * @param $dbName String: database name on the server
-        * @param $failFunction Callback (optional)
-        * @param $flags Integer: database behaviour flags (optional, unused)
-        * @return DatabaseIbm_db2 object
-        */
-       static function newFromParams( $server, $user, $password, $dbName,
-               $failFunction = false, $flags = 0 )
-       {
-               return new DatabaseIbm_db2( $server, $user, $password, $dbName,
-                       $failFunction, $flags );
-       }
-
        /**
         * Retrieves the most current database error
         * Forces a database rollback
@@ -611,7 +583,6 @@ EOF;
                        } else {
                                print '<li>Foreign keys done</li>';
                        }
-                       $res = null;
 
                        // TODO: populate interwiki links
 
@@ -758,7 +729,7 @@ EOF;
        function makeList( $a, $mode = LIST_COMMA ) {
                if ( !is_array( $a ) ) {
                        throw new DBUnexpectedError( $this,
-                               'DatabaseBase::makeList called with incorrect parameters' );
+                               'DatabaseIbm_db2::makeList called with incorrect parameters' );
                }
 
                // if this is for a prepared UPDATE statement
@@ -1042,7 +1013,7 @@ EOF;
         *                 more of IGNORE, LOW_PRIORITY
         * @return Boolean
         */
-       public function update( $table, $values, $conds, $fname = 'Database::update',
+       public function update( $table, $values, $conds, $fname = 'DatabaseIbm_db2::update',
                $options = array() )
        {
                $table = $this->tableName( $table );
@@ -1067,10 +1038,10 @@ EOF;
         *
         * Use $conds == "*" to delete all rows
         */
-       public function delete( $table, $conds, $fname = 'Database::delete' ) {
+       public function delete( $table, $conds, $fname = 'DatabaseIbm_db2::delete' ) {
                if ( !$conds ) {
                        throw new DBUnexpectedError( $this,
-                       'Database::delete() called with no conditions' );
+                               'DatabaseIbm_db2::delete() called with no conditions' );
                }
                $table = $this->tableName( $table );
                $sql = "DELETE FROM $table";
@@ -1254,11 +1225,9 @@ EOF;
                        $join_conds );
 
                // We must adjust for offset
-               if ( isset( $options['LIMIT'] ) ) {
-                       if ( isset ( $options['OFFSET'] ) ) {
-                               $limit = $options['LIMIT'];
-                               $offset = $options['OFFSET'];
-                       }
+               if ( isset( $options['LIMIT'] ) && isset ( $options['OFFSET'] ) ) {
+                       $limit = $options['LIMIT'];
+                       $offset = $options['OFFSET'];
                }
 
                // DB2 does not have a proper num_rows() function yet, so we must emulate
@@ -1470,7 +1439,7 @@ SQL;
         * @return Bool
         */
        public function indexUnique ( $table, $index,
-               $fname = 'Database::indexUnique' )
+               $fname = 'DatabaseIbm_db2::indexUnique' )
        {
                $table = $this->tableName( $table );
                $sql = <<<SQL
@@ -1525,7 +1494,7 @@ SQL;
        {
                if ( !$conds ) {
                        throw new DBUnexpectedError( $this,
-                       'Database::deleteJoin() called with empty $conds' );
+                               'DatabaseIbm_db2::deleteJoin() called with empty $conds' );
                }
 
                $delTable = $this->tableName( $delTable );