Ignore:
Timestamp:
2013/08/02 13:22:57 (11 years ago)
Author:
Seasoft
Message:

#2322 (セッションのGC処理がエラーとなる)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_13-dev/data/module/MDB2/Driver/pgsql.php

    r20119 r23022  
    4444// +----------------------------------------------------------------------+ 
    4545// 
    46 // $Id: pgsql.php,v 1.203 2008/11/29 14:04:46 afz Exp $ 
     46// $Id: pgsql.php 327317 2012-08-27 15:17:08Z danielc $ 
    4747 
    4848/** 
     
    212212        } 
    213213        $connection = $this->getConnection(); 
    214         if (PEAR::isError($connection)) { 
     214        if (MDB2::isError($connection)) { 
    215215            return $connection; 
    216216        } 
     
    237237    { 
    238238        $this->debug('Starting transaction/savepoint', __FUNCTION__, array('is_manip' => true, 'savepoint' => $savepoint)); 
    239         if (!is_null($savepoint)) { 
     239        if (null !== $savepoint) { 
    240240            if (!$this->in_transaction) { 
    241241                return $this->raiseError(MDB2_ERROR_INVALID, null, null, 
     
    244244            $query = 'SAVEPOINT '.$savepoint; 
    245245            return $this->_doQuery($query, true); 
    246         } elseif ($this->in_transaction) { 
     246        } 
     247        if ($this->in_transaction) { 
    247248            return MDB2_OK;  //nothing to do 
    248249        } 
     
    251252            register_shutdown_function('MDB2_closeOpenTransactions'); 
    252253        } 
    253         $result =& $this->_doQuery('BEGIN', true); 
    254         if (PEAR::isError($result)) { 
     254        $result = $this->_doQuery('BEGIN', true); 
     255        if (MDB2::isError($result)) { 
    255256            return $result; 
    256257        } 
     
    280281                'commit/release savepoint cannot be done changes are auto committed', __FUNCTION__); 
    281282        } 
    282         if (!is_null($savepoint)) { 
     283        if (null !== $savepoint) { 
    283284            $query = 'RELEASE SAVEPOINT '.$savepoint; 
    284285            return $this->_doQuery($query, true); 
    285286        } 
    286287 
    287         $result =& $this->_doQuery('COMMIT', true); 
    288         if (PEAR::isError($result)) { 
     288        $result = $this->_doQuery('COMMIT', true); 
     289        if (MDB2::isError($result)) { 
    289290            return $result; 
    290291        } 
     
    314315                'rollback cannot be done changes are auto committed', __FUNCTION__); 
    315316        } 
    316         if (!is_null($savepoint)) { 
     317        if (null !== $savepoint) { 
    317318            $query = 'ROLLBACK TO SAVEPOINT '.$savepoint; 
    318319            return $this->_doQuery($query, true); 
     
    320321 
    321322        $query = 'ROLLBACK'; 
    322         $result =& $this->_doQuery($query, true); 
    323         if (PEAR::isError($result)) { 
     323        $result = $this->_doQuery($query, true); 
     324        if (MDB2::isError($result)) { 
    324325            return $result; 
    325326        } 
     
    339340     *                  REPEATABLE READ (prevents nonrepeatable reads) 
    340341     *                  SERIALIZABLE (prevents phantom reads) 
     342     * @param   array some transaction options: 
     343     *                  'wait' => 'WAIT' | 'NO WAIT' 
     344     *                  'rw'   => 'READ WRITE' | 'READ ONLY' 
     345     * 
    341346     * @return  mixed   MDB2_OK on success, a MDB2 error on failure 
    342347     * 
     
    344349     * @since   2.1.1 
    345350     */ 
    346     function setTransactionIsolation($isolation) 
     351    function setTransactionIsolation($isolation, $options = array()) 
    347352    { 
    348353        $this->debug('Setting transaction isolation level', __FUNCTION__, array('is_manip' => true)); 
     
    373378    function _doConnect($username, $password, $database_name, $persistent = false) 
    374379    { 
    375         if (!PEAR::loadExtension($this->phptype)) { 
     380        if (!extension_loaded($this->phptype)) { 
    376381            return $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null, 
    377382                'extension '.$this->phptype.' is not compiled into PHP', __FUNCTION__); 
    378383        } 
    379          
     384 
    380385        if ($database_name == '') { 
    381386            $database_name = 'template1'; 
     
    448453        if (!empty($this->dsn['charset'])) { 
    449454            $result = $this->setCharset($this->dsn['charset'], $connection); 
    450             if (PEAR::isError($result)) { 
     455            if (MDB2::isError($result)) { 
    451456                return $result; 
     457            } 
     458        } 
     459 
     460        // Enable extra compatibility settings on 8.2 and later 
     461        if (function_exists('pg_parameter_status')) { 
     462            $version = pg_parameter_status($connection, 'server_version'); 
     463            if ($version == false) { 
     464                return $this->raiseError(null, null, null, 
     465                  'Unable to retrieve server version', __FUNCTION__); 
     466            } 
     467            $version = explode ('.', $version); 
     468            if (    $version['0'] > 8 
     469                || ($version['0'] == 8 && $version['1'] >= 2) 
     470            ) { 
     471                if (!@pg_query($connection, "SET SESSION STANDARD_CONFORMING_STRINGS = OFF")) { 
     472                    return $this->raiseError(null, null, null, 
     473                      'Unable to set standard_conforming_strings to off', __FUNCTION__); 
     474                } 
     475 
     476                if (!@pg_query($connection, "SET SESSION ESCAPE_STRING_WARNING = OFF")) { 
     477                    return $this->raiseError(null, null, null, 
     478                      'Unable to set escape_string_warning to off', __FUNCTION__); 
     479                } 
    452480            } 
    453481        } 
     
    483511                                            $this->database_name, 
    484512                                            $this->options['persistent']); 
    485             if (PEAR::isError($connection)) { 
     513            if (MDB2::isError($connection)) { 
    486514                return $connection; 
    487515            } 
     
    510538    function setCharset($charset, $connection = null) 
    511539    { 
    512         if (is_null($connection)) { 
     540        if (null === $connection) { 
    513541            $connection = $this->getConnection(); 
    514             if (PEAR::isError($connection)) { 
     542            if (MDB2::isError($connection)) { 
    515543                return $connection; 
    516544            } 
     
    545573                                 $this->escape($name), 
    546574                                 $this->options['persistent']); 
    547         if (!PEAR::isError($res)) { 
     575        if (!MDB2::isError($res)) { 
    548576            return true; 
    549577        } 
     
    596624    // {{{ standaloneQuery() 
    597625 
    598    /** 
     626    /** 
    599627     * execute a query as DBA 
    600628     * 
     
    606634     * @access public 
    607635     */ 
    608     function &standaloneQuery($query, $types = null, $is_manip = false) 
     636    function standaloneQuery($query, $types = null, $is_manip = false) 
    609637    { 
    610638        $user = $this->options['DBA_username']? $this->options['DBA_username'] : $this->dsn['username']; 
    611639        $pass = $this->options['DBA_password']? $this->options['DBA_password'] : $this->dsn['password']; 
    612640        $connection = $this->_doConnect($user, $pass, $this->database_name, $this->options['persistent']); 
    613         if (PEAR::isError($connection)) { 
     641        if (MDB2::isError($connection)) { 
    614642            return $connection; 
    615643        } 
     
    620648        $query = $this->_modifyQuery($query, $is_manip, $limit, $offset); 
    621649 
    622         $result =& $this->_doQuery($query, $is_manip, $connection, $this->database_name); 
    623         if (!PEAR::isError($result)) { 
     650        $result = $this->_doQuery($query, $is_manip, $connection, $this->database_name); 
     651        if (!MDB2::isError($result)) { 
    624652            if ($is_manip) { 
    625653                $result =  $this->_affectedRows($connection, $result); 
    626654            } else { 
    627                 $result =& $this->_wrapResult($result, $types, true, false, $limit, $offset); 
     655                $result = $this->_wrapResult($result, $types, true, true, $limit, $offset); 
    628656            } 
    629657        } 
     
    645673     * @access protected 
    646674     */ 
    647     function &_doQuery($query, $is_manip = false, $connection = null, $database_name = null) 
     675    function _doQuery($query, $is_manip = false, $connection = null, $database_name = null) 
    648676    { 
    649677        $this->last_query = $query; 
    650678        $result = $this->debug($query, 'query', array('is_manip' => $is_manip, 'when' => 'pre')); 
    651679        if ($result) { 
    652             if (PEAR::isError($result)) { 
     680            if (MDB2::isError($result)) { 
    653681                return $result; 
    654682            } 
     
    660688        } 
    661689 
    662         if (is_null($connection)) { 
     690        if (null === $connection) { 
    663691            $connection = $this->getConnection(); 
    664             if (PEAR::isError($connection)) { 
     692            if (MDB2::isError($connection)) { 
    665693                return $connection; 
    666694            } 
     
    670698        $result = @$function($connection, $query); 
    671699        if (!$result) { 
    672             $err =& $this->raiseError(null, null, null, 
     700            $err = $this->raiseError(null, null, null, 
    673701                'Could not execute statement', __FUNCTION__); 
    674702            return $err; 
    675703        } elseif ($this->options['multi_query']) { 
    676704            if (!($result = @pg_get_result($connection))) { 
    677                 $err =& $this->raiseError(null, null, null, 
     705                $err = $this->raiseError(null, null, null, 
    678706                        'Could not get the first result from a multi query', __FUNCTION__); 
    679707                return $err; 
     
    698726    function _affectedRows($connection, $result = null) 
    699727    { 
    700         if (is_null($connection)) { 
     728        if (null === $connection) { 
    701729            $connection = $this->getConnection(); 
    702             if (PEAR::isError($connection)) { 
     730            if (MDB2::isError($connection)) { 
    703731                return $connection; 
    704732            } 
     
    737765        return $query; 
    738766    } 
    739      
     767 
    740768    // }}} 
    741769    // {{{ _modifyManipQuery() 
    742      
     770 
    743771    /** 
    744772     * Changes a manip query string for various DBMS specific reasons 
     
    786814        } else { 
    787815            $server_info = $this->queryOne($query, 'text'); 
    788             if (PEAR::isError($server_info)) { 
     816            if (MDB2::isError($server_info)) { 
    789817                return $server_info; 
    790818            } 
     
    792820        // cache server_info 
    793821        $this->connected_server_info = $server_info; 
    794         if (!$native && !PEAR::isError($server_info)) { 
     822        if (!$native && !MDB2::isError($server_info)) { 
    795823            $tmp = explode('.', $server_info, 3); 
    796824            if (empty($tmp[2]) 
     
    842870     * @see bindParam, execute 
    843871     */ 
    844     function &prepare($query, $types = null, $result_types = null, $lobs = array()) 
     872    function prepare($query, $types = null, $result_types = null, $lobs = array()) 
    845873    { 
    846874        if ($this->options['emulate_prepared']) { 
    847             $obj =& parent::prepare($query, $types, $result_types, $lobs); 
    848             return $obj; 
     875            return parent::prepare($query, $types, $result_types, $lobs); 
    849876        } 
    850877        $is_manip = ($result_types === MDB2_PREPARE_MANIP); 
     
    854881        $result = $this->debug($query, __FUNCTION__, array('is_manip' => $is_manip, 'when' => 'pre')); 
    855882        if ($result) { 
    856             if (PEAR::isError($result)) { 
     883            if (MDB2::isError($result)) { 
    857884                return $result; 
    858885            } 
     
    886913                break; 
    887914            } 
    888             if (is_null($placeholder_type)) { 
     915            if (null === $placeholder_type) { 
    889916                $placeholder_type_guess = $query[$p_position]; 
    890917            } 
    891              
     918 
    892919            $new_pos = $this->_skipDelimitedStrings($query, $position, $p_position); 
    893             if (PEAR::isError($new_pos)) { 
     920            if (MDB2::isError($new_pos)) { 
    894921                return $new_pos; 
    895922            } 
     
    900927 
    901928            if ($query[$position] == $placeholder_type_guess) { 
    902                 if (is_null($placeholder_type)) { 
     929                if (null === $placeholder_type) { 
    903930                    $placeholder_type = $query[$p_position]; 
    904931                    $question = $colon = $placeholder_type; 
     
    917944                    $param = preg_replace($regexp, '\\1', $query); 
    918945                    if ($param === '') { 
    919                         $err =& $this->raiseError(MDB2_ERROR_SYNTAX, null, null, 
     946                        $err = $this->raiseError(MDB2_ERROR_SYNTAX, null, null, 
    920947                            'named parameter name must match "bindname_format" option', __FUNCTION__); 
    921948                        return $err; 
     
    930957                        $pgtypes[] = $this->datatype->mapPrepareDatatype($types[$parameter]); 
    931958                    } else { 
    932                         if (version_compare(PHP_VERSION, '5.0.0', '>')) { 
    933                             $pgtypes[] = 'text'; 
    934                         } 
     959                        $pgtypes[] = 'text'; 
    935960                    } 
    936961                } 
    937                 if (($key_parameter = array_search($name, $positions))) { 
    938                     $next_parameter = 1; 
    939                     foreach ($positions as $key => $value) { 
    940                         if ($key_parameter == $key) { 
    941                             break; 
    942                         } 
    943                         ++$next_parameter; 
    944                     } 
     962                if (($key_parameter = array_search($name, $positions)) !== false) { 
     963                    //$next_parameter = 1; 
     964                    $parameter = $key_parameter + 1; 
     965                    //foreach ($positions as $key => $value) { 
     966                    //    if ($key_parameter == $key) { 
     967                    //        break; 
     968                    //    } 
     969                    //    ++$next_parameter; 
     970                    //} 
    945971                } else { 
    946972                    ++$parameter; 
    947                     $next_parameter = $parameter; 
     973                    //$next_parameter = $parameter; 
    948974                    $positions[] = $name; 
    949975                } 
     
    955981        } 
    956982        $connection = $this->getConnection(); 
    957         if (PEAR::isError($connection)) { 
     983        if (MDB2::isError($connection)) { 
    958984            return $connection; 
    959985        } 
     
    961987        $statement_name = sprintf($this->options['statement_format'], $this->phptype, $prep_statement_counter++ . sha1(microtime() + mt_rand())); 
    962988        $statement_name = substr(strtolower($statement_name), 0, $this->options['max_identifiers_length']); 
    963         if ($pgtypes === false) { 
     989        if (false === $pgtypes) { 
    964990            $result = @pg_prepare($connection, $statement_name, $query); 
    965991            if (!$result) { 
    966                 $err =& $this->raiseError(null, null, null, 
     992                $err = $this->raiseError(null, null, null, 
    967993                    'Unable to create prepared statement handle', __FUNCTION__); 
    968994                return $err; 
     
    9741000            } 
    9751001            $query = 'PREPARE '.$statement_name.$types_string.' AS '.$query; 
    976             $statement =& $this->_doQuery($query, true, $connection); 
    977             if (PEAR::isError($statement)) { 
     1002            $statement = $this->_doQuery($query, true, $connection); 
     1003            if (MDB2::isError($statement)) { 
    9781004                return $statement; 
    9791005            } 
     
    10051031            } 
    10061032            $schema_list = $this->queryOne("SELECT array_to_string(current_schemas(false), ',')"); 
    1007             if (PEAR::isError($schema_list) || empty($schema_list) || count($schema_list) < 2) { 
     1033            if (MDB2::isError($schema_list) || empty($schema_list) || count($schema_list) < 2) { 
    10081034                $order_by = ' a.attnum'; 
    10091035                $schema_clause = ' AND n.nspname=current_schema()'; 
     
    10401066                    ORDER BY ".$order_by; 
    10411067            $seqname = $this->queryOne($query); 
    1042             if (!PEAR::isError($seqname) && !empty($seqname) && is_string($seqname)) { 
     1068            if (!MDB2::isError($seqname) && !empty($seqname) && is_string($seqname)) { 
    10431069                return $seqname; 
    10441070            } 
     
    10701096        $this->popExpect(); 
    10711097        $this->popErrorHandling(); 
    1072         if (PEAR::isError($result)) { 
     1098        if (MDB2::isError($result)) { 
    10731099            if ($ondemand && $result->getCode() == MDB2_ERROR_NOSUCHTABLE) { 
    10741100                $this->loadModule('Manager', null, true); 
    10751101                $result = $this->manager->createSequence($seq_name); 
    1076                 if (PEAR::isError($result)) { 
     1102                if (MDB2::isError($result)) { 
    10771103                    return $this->raiseError($result, null, null, 
    10781104                        'on demand sequence could not be created', __FUNCTION__); 
     
    11431169     * @access public 
    11441170     */ 
    1145     function &fetchRow($fetchmode = MDB2_FETCHMODE_DEFAULT, $rownum = null) 
    1146     { 
    1147         if (!is_null($rownum)) { 
     1171    function fetchRow($fetchmode = MDB2_FETCHMODE_DEFAULT, $rownum = null) 
     1172    { 
     1173        if (null !== $rownum) { 
    11481174            $seek = $this->seek($rownum); 
    1149             if (PEAR::isError($seek)) { 
     1175            if (MDB2::isError($seek)) { 
    11501176                return $seek; 
    11511177            } 
     
    11541180            $fetchmode = $this->db->fetchmode; 
    11551181        } 
    1156         if ($fetchmode & MDB2_FETCHMODE_ASSOC) { 
     1182        if (   $fetchmode == MDB2_FETCHMODE_ASSOC 
     1183            || $fetchmode == MDB2_FETCHMODE_OBJECT 
     1184        ) { 
    11571185            $row = @pg_fetch_array($this->result, null, PGSQL_ASSOC); 
    11581186            if (is_array($row) 
     
    11651193        } 
    11661194        if (!$row) { 
    1167             if ($this->result === false) { 
    1168                 $err =& $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 
     1195            if (false === $this->result) { 
     1196                $err = $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 
    11691197                    'resultset has already been freed', __FUNCTION__); 
    11701198                return $err; 
    11711199            } 
    1172             $null = null; 
    1173             return $null; 
     1200            return null; 
    11741201        } 
    11751202        $mode = $this->db->options['portability'] & MDB2_PORTABILITY_EMPTY_TO_NULL; 
     
    11851212            $this->db->_fixResultArrayValues($row, $mode); 
    11861213        } 
    1187         if (!empty($this->types)) { 
     1214        if (   (   $fetchmode != MDB2_FETCHMODE_ASSOC 
     1215                && $fetchmode != MDB2_FETCHMODE_OBJECT) 
     1216            && !empty($this->types) 
     1217        ) { 
    11881218            $row = $this->db->datatype->convertResultRow($this->types, $row, $rtrim); 
     1219        } elseif (($fetchmode == MDB2_FETCHMODE_ASSOC 
     1220                || $fetchmode == MDB2_FETCHMODE_OBJECT) 
     1221            && !empty($this->types_assoc) 
     1222        ) { 
     1223            $row = $this->db->datatype->convertResultRow($this->types_assoc, $row, $rtrim); 
    11891224        } 
    11901225        if (!empty($this->values)) { 
     
    11961231                $row = (object) $row; 
    11971232            } else { 
    1198                 $row = &new $object_class($row); 
     1233                $rowObj = new $object_class($row); 
     1234                $row = $rowObj; 
    11991235            } 
    12001236        } 
     
    12191255        $columns = array(); 
    12201256        $numcols = $this->numCols(); 
    1221         if (PEAR::isError($numcols)) { 
     1257        if (MDB2::isError($numcols)) { 
    12221258            return $numcols; 
    12231259        } 
     
    12451281    { 
    12461282        $cols = @pg_num_fields($this->result); 
    1247         if (is_null($cols)) { 
    1248             if ($this->result === false) { 
     1283        if (null === $cols) { 
     1284            if (false === $this->result) { 
    12491285                return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 
    12501286                    'resultset has already been freed', __FUNCTION__); 
    1251             } elseif (is_null($this->result)) { 
     1287            } 
     1288            if (null === $this->result) { 
    12521289                return count($this->types); 
    12531290            } 
     
    12701307    { 
    12711308        $connection = $this->db->getConnection(); 
    1272         if (PEAR::isError($connection)) { 
     1309        if (MDB2::isError($connection)) { 
    12731310            return $connection; 
    12741311        } 
     
    12931330        if (is_resource($this->result) && $this->db->connection) { 
    12941331            $free = @pg_free_result($this->result); 
    1295             if ($free === false) { 
     1332            if (false === $free) { 
    12961333                return $this->db->raiseError(null, null, null, 
    12971334                    'Could not free result', __FUNCTION__); 
     
    13241361    { 
    13251362        if ($this->rownum != ($rownum - 1) && !@pg_result_seek($this->result, $rownum)) { 
    1326             if ($this->result === false) { 
     1363            if (false === $this->result) { 
    13271364                return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 
    13281365                    'resultset has already been freed', __FUNCTION__); 
    1329             } elseif (is_null($this->result)) { 
     1366            } 
     1367            if (null === $this->result) { 
    13301368                return MDB2_OK; 
    13311369            } 
     
    13491387    { 
    13501388        $numrows = $this->numRows(); 
    1351         if (PEAR::isError($numrows)) { 
     1389        if (MDB2::isError($numrows)) { 
    13521390            return $numrows; 
    13531391        } 
     
    13671405    { 
    13681406        $rows = @pg_num_rows($this->result); 
    1369         if (is_null($rows)) { 
    1370             if ($this->result === false) { 
     1407        if (null === $rows) { 
     1408            if (false === $this->result) { 
    13711409                return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 
    13721410                    'resultset has already been freed', __FUNCTION__); 
    1373             } elseif (is_null($this->result)) { 
     1411            } 
     1412            if (null === $this->result) { 
    13741413                return 0; 
    13751414            } 
     
    14021441     * @access private 
    14031442     */ 
    1404     function &_execute($result_class = true, $result_wrap_class = false) 
    1405     { 
    1406         if (is_null($this->statement)) { 
    1407             $result =& parent::_execute($result_class, $result_wrap_class); 
    1408             return $result; 
     1443    function _execute($result_class = true, $result_wrap_class = true) 
     1444    { 
     1445        if (null === $this->statement) { 
     1446            return parent::_execute($result_class, $result_wrap_class); 
    14091447        } 
    14101448        $this->db->last_query = $this->query; 
     
    14161454 
    14171455        $connection = $this->db->getConnection(); 
    1418         if (PEAR::isError($connection)) { 
     1456        if (MDB2::isError($connection)) { 
    14191457            return $connection; 
    14201458        } 
     
    14541492                } 
    14551493                $quoted = $this->db->quote($value, $type, $query); 
    1456                 if (PEAR::isError($quoted)) { 
     1494                if (MDB2::isError($quoted)) { 
    14571495                    return $quoted; 
    14581496                } 
     
    14671505            $result = @pg_execute($connection, $this->statement, $parameters); 
    14681506            if (!$result) { 
    1469                 $err =& $this->db->raiseError(null, null, null, 
     1507                $err = $this->db->raiseError(null, null, null, 
    14701508                    'Unable to execute statement', __FUNCTION__); 
    14711509                return $err; 
     
    14731511        } else { 
    14741512            $result = $this->db->_doQuery($query, $this->is_manip, $connection); 
    1475             if (PEAR::isError($result)) { 
     1513            if (MDB2::isError($result)) { 
    14761514                return $result; 
    14771515            } 
     
    14831521        } 
    14841522 
    1485         $result =& $this->db->_wrapResult($result, $this->result_types, 
     1523        $result = $this->db->_wrapResult($result, $this->result_types, 
    14861524            $result_class, $result_wrap_class, $this->limit, $this->offset); 
    14871525        $this->db->debug($this->query, 'execute', array('is_manip' => $this->is_manip, 'when' => 'post', 'result' => $result)); 
     
    15001538    function free() 
    15011539    { 
    1502         if (is_null($this->positions)) { 
     1540        if (null === $this->positions) { 
    15031541            return $this->db->raiseError(MDB2_ERROR, null, null, 
    15041542                'Prepared statement has already been freed', __FUNCTION__); 
     
    15061544        $result = MDB2_OK; 
    15071545 
    1508         if (!is_null($this->statement)) { 
     1546        if (null !== $this->statement) { 
    15091547            $connection = $this->db->getConnection(); 
    1510             if (PEAR::isError($connection)) { 
     1548            if (MDB2::isError($connection)) { 
    15111549                return $connection; 
    15121550            } 
     
    15181556        return $result; 
    15191557    } 
     1558 
     1559    /** 
     1560     * drop an existing table 
     1561     * 
     1562     * @param string $name name of the table that should be dropped 
     1563     * @return mixed MDB2_OK on success, a MDB2 error on failure 
     1564     * @access public 
     1565     */ 
     1566    function dropTable($name) 
     1567    { 
     1568        $db = $this->getDBInstance(); 
     1569        if (MDB2::isError($db)) { 
     1570            return $db; 
     1571        } 
     1572 
     1573        $name = $db->quoteIdentifier($name, true); 
     1574        $result = $db->exec("DROP TABLE $name"); 
     1575 
     1576        if (MDB2::isError($result)) { 
     1577            $result = $db->exec("DROP TABLE $name CASCADE"); 
     1578        } 
     1579 
     1580       return $result; 
     1581    } 
    15201582} 
    15211583?> 
Note: See TracChangeset for help on using the changeset viewer.