From d1403fd7268ccf96ab6e7d04506ea1b1802c7eb2 Mon Sep 17 00:00:00 2001 From: alecpl <alec@alec.pl> Date: Fri, 02 May 2008 03:35:00 -0400 Subject: [PATCH] - fixed #1485032 and updated MDB2 package+drivers --- program/lib/MDB2/Driver/Datatype/mysqli.php | 92 ++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 89 insertions(+), 3 deletions(-) diff --git a/program/lib/MDB2/Driver/Datatype/mysqli.php b/program/lib/MDB2/Driver/Datatype/mysqli.php index 40f70f2..deba919 100644 --- a/program/lib/MDB2/Driver/Datatype/mysqli.php +++ b/program/lib/MDB2/Driver/Datatype/mysqli.php @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: mysqli.php,v 1.61 2007/11/09 20:54:58 quipo Exp $ +// $Id: mysqli.php,v 1.63 2008/02/22 19:23:49 quipo Exp $ // require_once 'MDB2/Driver/Datatype/Common.php'; @@ -232,6 +232,93 @@ $field['default'] = empty($field['notnull']) ? null : 0; } $default = ' DEFAULT '.$this->quote($field['default'], 'integer'); + } + + $notnull = empty($field['notnull']) ? '' : ' NOT NULL'; + $unsigned = empty($field['unsigned']) ? '' : ' UNSIGNED'; + $name = $db->quoteIdentifier($name, true); + return $name.' '.$this->getTypeDeclaration($field).$unsigned.$default.$notnull.$autoinc; + } + + // }}} + // {{{ _getFloatDeclaration() + + /** + * Obtain DBMS specific SQL code portion needed to declare an float type + * field to be used in statements like CREATE TABLE. + * + * @param string $name name the field to be declared. + * @param string $field associative array with the name of the properties + * of the field being declared as array indexes. + * Currently, the types of supported field + * properties are as follows: + * + * unsigned + * Boolean flag that indicates whether the field + * should be declared as unsigned float if + * possible. + * + * default + * float value to be used as default for this + * field. + * + * notnull + * Boolean flag that indicates whether this field is + * constrained to not be set to null. + * @return string DBMS specific SQL code portion that should be used to + * declare the specified field. + * @access protected + */ + function _getFloatDeclaration($name, $field) + { + // Since AUTO_INCREMENT can be used for integer or floating-point types, + // reuse the INTEGER declaration + // @see http://bugs.mysql.com/bug.php?id=31032 + return $this->_getIntegerDeclaration($name, $field); + } + + // }}} + // {{{ _getDecimalDeclaration() + + /** + * Obtain DBMS specific SQL code portion needed to declare an decimal type + * field to be used in statements like CREATE TABLE. + * + * @param string $name name the field to be declared. + * @param string $field associative array with the name of the properties + * of the field being declared as array indexes. + * Currently, the types of supported field + * properties are as follows: + * + * unsigned + * Boolean flag that indicates whether the field + * should be declared as unsigned integer if + * possible. + * + * default + * Decimal value to be used as default for this + * field. + * + * notnull + * Boolean flag that indicates whether this field is + * constrained to not be set to null. + * @return string DBMS specific SQL code portion that should be used to + * declare the specified field. + * @access protected + */ + function _getDecimalDeclaration($name, $field) + { + $db =& $this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + $default = ''; + if (array_key_exists('default', $field)) { + if ($field['default'] === '') { + $field['default'] = empty($field['notnull']) ? null : 0; + } + $default = ' DEFAULT '.$this->quote($field['default'], 'integer'); } elseif (empty($field['notnull'])) { $default = ' DEFAULT NULL'; } @@ -239,7 +326,7 @@ $notnull = empty($field['notnull']) ? '' : ' NOT NULL'; $unsigned = empty($field['unsigned']) ? '' : ' UNSIGNED'; $name = $db->quoteIdentifier($name, true); - return $name.' '.$this->getTypeDeclaration($field).$unsigned.$default.$notnull.$autoinc; + return $name.' '.$this->getTypeDeclaration($field).$unsigned.$default.$notnull; } // }}} @@ -355,7 +442,6 @@ case 'tinytext': case 'mediumtext': case 'longtext': - case 'text': case 'text': case 'varchar': $fixed = false; -- Gitblit v1.9.1