- Timestamp:
- 2013/08/02 13:22:57 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_13-dev/data/module/MDB2/Driver/Reverse/pgsql.php
r20764 r23022 44 44 // +----------------------------------------------------------------------+ 45 45 // 46 // $Id: pgsql.php ,v 1.75 2008/08/22 16:36:20 quipo Exp$46 // $Id: pgsql.php 327310 2012-08-27 15:16:18Z danielc $ 47 47 48 48 require_once 'MDB2/Driver/Reverse/Common.php'; … … 70 70 function getTableFieldDefinition($table_name, $field_name) 71 71 { 72 $db = &$this->getDBInstance();73 if ( PEAR::isError($db)) {72 $db = $this->getDBInstance(); 73 if (MDB2::isError($db)) { 74 74 return $db; 75 75 } 76 76 77 77 $result = $db->loadModule('Datatype', null, true); 78 if ( PEAR::isError($result)) {78 if (MDB2::isError($result)) { 79 79 return $result; 80 80 } … … 123 123 ORDER BY a.attnum"; 124 124 $column = $db->queryRow($query, null, MDB2_FETCHMODE_ASSOC); 125 if ( PEAR::isError($column)) {125 if (MDB2::isError($column)) { 126 126 return $column; 127 127 } … … 134 134 $column = array_change_key_case($column, CASE_LOWER); 135 135 $mapped_datatype = $db->datatype->mapNativeDatatype($column); 136 if ( PEAR::isError($mapped_datatype)) {136 if (MDB2::isError($mapped_datatype)) { 137 137 return $mapped_datatype; 138 138 } … … 144 144 $default = null; 145 145 if ($column['atthasdef'] === 't' 146 && strpos($column['default'], 'NULL') !== 0 146 147 && !preg_match("/nextval\('([^']+)'/", $column['default']) 147 148 ) { 148 149 $pattern = '/^\'(.*)\'::[\w ]+$/i'; 149 150 $default = $column['default'];#substr($column['adsrc'], 1, -1); 150 if ( is_null($default) && $notnull) {151 if ((null === $default) && $notnull) { 151 152 $default = ''; 152 153 } elseif (!empty($default) && preg_match($pattern, $default)) { … … 160 161 } 161 162 $definition[0] = array('notnull' => $notnull, 'nativetype' => $column['type']); 162 if ( !is_null($length)) {163 if (null !== $length) { 163 164 $definition[0]['length'] = $length; 164 165 } 165 if ( !is_null($unsigned)) {166 if (null !== $unsigned) { 166 167 $definition[0]['unsigned'] = $unsigned; 167 168 } 168 if ( !is_null($fixed)) {169 if (null !== $fixed) { 169 170 $definition[0]['fixed'] = $fixed; 170 171 } … … 199 200 function getTableIndexDefinition($table_name, $index_name) 200 201 { 201 $db = &$this->getDBInstance();202 if ( PEAR::isError($db)) {202 $db = $this->getDBInstance(); 203 if (MDB2::isError($db)) { 203 204 return $db; 204 205 } … … 212 213 $index_name_mdb2 = $db->getIndexName($index_name); 213 214 $row = $db->queryRow(sprintf($query, $db->quote($index_name_mdb2, 'text')), null, MDB2_FETCHMODE_ASSOC); 214 if ( PEAR::isError($row) || empty($row)) {215 if (MDB2::isError($row) || empty($row)) { 215 216 // fallback to the given $index_name, without transformation 216 217 $row = $db->queryRow(sprintf($query, $db->quote($index_name, 'text')), null, MDB2_FETCHMODE_ASSOC); 217 218 } 218 if ( PEAR::isError($row)) {219 if (MDB2::isError($row)) { 219 220 return $row; 220 221 } … … 257 258 function getTableConstraintDefinition($table_name, $constraint_name) 258 259 { 259 $db = &$this->getDBInstance();260 if ( PEAR::isError($db)) {260 $db = $this->getDBInstance(); 261 if (MDB2::isError($db)) { 261 262 return $db; 262 263 } … … 303 304 $constraint_name_mdb2 = $db->getIndexName($constraint_name); 304 305 $row = $db->queryRow(sprintf($query, $db->quote($constraint_name_mdb2, 'text')), null, MDB2_FETCHMODE_ASSOC); 305 if ( PEAR::isError($row) || empty($row)) {306 if (MDB2::isError($row) || empty($row)) { 306 307 // fallback to the given $index_name, without transformation 307 308 $constraint_name_mdb2 = $constraint_name; 308 309 $row = $db->queryRow(sprintf($query, $db->quote($constraint_name_mdb2, 'text')), null, MDB2_FETCHMODE_ASSOC); 309 310 } 310 if ( PEAR::isError($row)) {311 if (MDB2::isError($row)) { 311 312 return $row; 312 313 } … … 333 334 $constraint_name_mdb2 = $db->getIndexName($constraint_name); 334 335 $row = $db->queryRow(sprintf($query, $db->quote($constraint_name_mdb2, 'text')), null, MDB2_FETCHMODE_ASSOC); 335 if ( PEAR::isError($row) || empty($row)) {336 if (MDB2::isError($row) || empty($row)) { 336 337 // fallback to the given $index_name, without transformation 337 338 $constraint_name_mdb2 = $constraint_name; 338 339 $row = $db->queryRow(sprintf($query, $db->quote($constraint_name_mdb2, 'text')), null, MDB2_FETCHMODE_ASSOC); 339 340 } 340 if ( PEAR::isError($row)) {341 if (MDB2::isError($row)) { 341 342 return $row; 342 343 } … … 388 389 AND t.relname = ' . $db->quote($table, 'text'); 389 390 $fields = $db->queryCol(sprintf($query, $db->quote($constraint_name_mdb2, 'text')), null); 390 if ( PEAR::isError($fields)) {391 if (MDB2::isError($fields)) { 391 392 return $fields; 392 393 } … … 407 408 AND t.relname = ' . $db->quote($definition['references']['table'], 'text'); 408 409 $foreign_fields = $db->queryCol(sprintf($query, $db->quote($constraint_name_mdb2, 'text')), null); 409 if ( PEAR::isError($foreign_fields)) {410 if (MDB2::isError($foreign_fields)) { 410 411 return $foreign_fields; 411 412 } … … 444 445 function getTriggerDefinition($trigger) 445 446 { 446 $db = &$this->getDBInstance();447 if ( PEAR::isError($db)) {447 $db = $this->getDBInstance(); 448 if (MDB2::isError($db)) { 448 449 return $db; 449 450 } … … 518 519 } 519 520 520 $db = &$this->getDBInstance();521 if ( PEAR::isError($db)) {521 $db = $this->getDBInstance(); 522 if (MDB2::isError($db)) { 522 523 return $db; 523 524 } … … 556 557 ); 557 558 $mdb2type_info = $db->datatype->mapNativeDatatype($res[$i]); 558 if ( PEAR::isError($mdb2type_info)) {559 if (MDB2::isError($mdb2type_info)) { 559 560 return $mdb2type_info; 560 561 }
Note: See TracChangeset
for help on using the changeset viewer.