[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pear-cvs
Subject:    [PEAR-CVS] cvs: pear /MDB2/MDB2/Driver/Datatype mysql.php
From:       "Ali Fazelzadeh" <afz () php ! net>
Date:       2008-01-31 2:07:57
Message-ID: cvsafz1201745277 () cvsserver
[Download RAW message or body]

afz		Thu Jan 31 02:07:57 2008 UTC

  Modified files:              
    /pear/MDB2/MDB2/Driver/Datatype	mysql.php 
  Log:
  support autoinc for float field type and unsigned option for float and decimal \
field type in mysql(#11204)  
http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/Datatype/mysql.php?r1=1.62&r2=1.63&diff_format=u
                
Index: pear/MDB2/MDB2/Driver/Datatype/mysql.php
diff -u pear/MDB2/MDB2/Driver/Datatype/mysql.php:1.62 \
                pear/MDB2/MDB2/Driver/Datatype/mysql.php:1.63
--- pear/MDB2/MDB2/Driver/Datatype/mysql.php:1.62	Fri Nov  9 20:54:58 2007
+++ pear/MDB2/MDB2/Driver/Datatype/mysql.php	Thu Jan 31 02:07:57 2008
@@ -43,7 +43,7 @@
 // | Author: Lukas Smith <smith@pooteeweet.org>                           |
 // +----------------------------------------------------------------------+
 //
-// $Id: mysql.php,v 1.62 2007/11/09 20:54:58 quipo Exp $
+// $Id: mysql.php,v 1.63 2008/01/31 02:07:57 afz Exp $
 //
 
 require_once 'MDB2/Driver/Datatype/Common.php';
@@ -243,6 +243,92 @@
     }
 
     // }}}
+    // {{{ _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)
+    {
+        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';
+        }
+
+        $notnull = empty($field['notnull']) ? '' : ' NOT NULL';
+        $unsigned = empty($field['unsigned']) ? '' : ' UNSIGNED';
+        $name = $db->quoteIdentifier($name, true);
+        return $name.' \
'.$this->getTypeDeclaration($field).$unsigned.$default.$notnull; +    }
+
+    // }}}
     // {{{ matchPattern()
 
     /**

-- 
PEAR CVS Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic