cvs: pear /DB_Table/DB/Table Manager.php

From: Date: Sun, 26 Feb 2006 15:53:50 +0000
Subject: cvs: pear /DB_Table/DB/Table Manager.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-38641@lists.php.net to get a copy of this message
wiesemann Sun Feb 26 15:53:50 2006 UTC Modified files: /pear/DB_Table/DB/Table Manager.php Log: - clean-up - pgsql fix - refactoring fix (max_scope detection was broken) http://cvs.php.net/viewcvs.cgi/pear/DB_Table/DB/Table/Manager.php?r1=1.26&r2=1.27&diff_format=u Index: pear/DB_Table/DB/Table/Manager.php diff -u pear/DB_Table/DB/Table/Manager.php:1.26 pear/DB_Table/DB/Table/Manager.php:1.27 --- pear/DB_Table/DB/Table/Manager.php:1.26 Sat Feb 25 18:07:15 2006 +++ pear/DB_Table/DB/Table/Manager.php Sun Feb 26 15:53:50 2006 @@ -16,7 +16,7 @@ * * @license http://www.gnu.org/copyleft/lesser.html LGPL * -* @version $Id: Manager.php,v 1.26 2006/02/25 18:07:15 wiesemann Exp $ +* @version $Id: Manager.php,v 1.27 2006/02/26 15:53:50 wiesemann Exp $ * */ @@ -268,7 +268,7 @@ // get the declaration string $column[$colname] = DB_Table_Manager::getDeclareMDB2($type, - $size, $scope, $require, $default); + $size, $scope, $require, $default, $max_scope); } else { @@ -622,7 +622,6 @@ if (PEAR::isError($definition)) { return $definition; } -# $changes = array('add' => array($colname => array($definition))); $changes = array('add' => array($colname => $definition)); if (array_key_exists('debug', $GLOBALS['_DB_TABLE'])) { echo "(alter) New table field will be added ($colname):\n"; @@ -654,9 +653,9 @@ if (PEAR::isError($definition)) { return $definition; } -# $changes = array('change' => array($colname => array($definition))); - $changes = array('change' => array($colname => array('definition' => $definition))); -# $changes = array('change' => array($colname => $definition)); + $changes = array('change' => + array($colname => array('type' => null, + 'definition' => $definition))); if (array_key_exists('debug', $GLOBALS['_DB_TABLE'])) { echo "(alter) Table field's type will be changed ($colname):\n"; var_dump($changes); @@ -710,7 +709,7 @@ $db->setOption('idxname_format', '%s'); } // drop index/constraint only if it exists - foreach(array('normal', 'unique', 'primary') as $idx_type) { + foreach (array('normal', 'unique', 'primary') as $idx_type) { if (array_key_exists(strtolower($newIdxName), $table_indexes[$idx_type])) { if (array_key_exists('debug', $GLOBALS['_DB_TABLE'])) { @@ -897,6 +896,9 @@ if ($phptype == 'ibase') { // Firebird does not like 'NULL' $null = ''; // in CREATE TABLE } + if ($phptype == 'pgsql') { // PostgreSQL does not like 'NULL' + $null = ''; // in ALTER TABLE + } $declare .= ($require) ? ' NOT NULL' : $null; // set the "DEFAULT" portion @@ -939,13 +941,16 @@ * * @param string $default The SQL calculation for a default value. * + * @param int $max_scope The maximal scope for all table column + * (pass-by-reference). + * * @return string|object A MDB2 column definition array on success, or a * PEAR_Error on failure. * */ function getDeclareMDB2($coltype, $size = null, $scope = null, - $require = null, $default = null) + $require = null, $default = null, &$max_scope) { // validate char/varchar/decimal type declaration $validation = DB_Table_Manager::_validateTypeDeclaration($coltype, $size, @@ -1085,6 +1090,8 @@ function _getColumnDefinition($backend, $phptype, $column) { + static $max_scope; + // prepare variables $type = (isset($column['type'])) ? $column['type'] : null; $size = (isset($column['size'])) ? $column['size'] : null; @@ -1097,7 +1104,7 @@ $size, $scope, $require, $default); } else { return DB_Table_Manager::getDeclareMDB2($type, - $size, $scope, $require, $default); + $size, $scope, $require, $default, $max_scope); } } @@ -1634,7 +1641,6 @@ unset($cols[$key]); } } - #unset($table_indexes[$type][$index_name]); break; } }

« previous php.pear.cvs (#38641) next »