MDB2
[ class tree: MDB2 ] [ index: MDB2 ] [ all elements ]

Source for file ibase.php

Documentation is available at ibase.php

  1. <?php
  2. // vim: set et ts=4 sw=4 fdm=marker:
  3. // +----------------------------------------------------------------------+
  4. // | PHP versions 4 and 5                                                 |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1998-2004 Manuel Lemos, Tomas V.V.Cox,                 |
  7. // | Stig. S. Bakken, Lukas Smith                                         |
  8. // | All rights reserved.                                                 |
  9. // +----------------------------------------------------------------------+
  10. // | MDB2 is a merge of PEAR DB and Metabases that provides a unified DB  |
  11. // | API as well as database abstraction for PHP applications.            |
  12. // | This LICENSE is in the BSD license style.                            |
  13. // |                                                                      |
  14. // | Redistribution and use in source and binary forms, with or without   |
  15. // | modification, are permitted provided that the following conditions   |
  16. // | are met:                                                             |
  17. // |                                                                      |
  18. // | Redistributions of source code must retain the above copyright       |
  19. // | notice, this list of conditions and the following disclaimer.        |
  20. // |                                                                      |
  21. // | Redistributions in binary form must reproduce the above copyright    |
  22. // | notice, this list of conditions and the following disclaimer in the  |
  23. // | documentation and/or other materials provided with the distribution. |
  24. // |                                                                      |
  25. // | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken,    |
  26. // | Lukas Smith nor the names of his contributors may be used to endorse |
  27. // | or promote products derived from this software without specific prior|
  28. // | written permission.                                                  |
  29. // |                                                                      |
  30. // | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS  |
  31. // | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT    |
  32. // | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS    |
  33. // | FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE      |
  34. // | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,          |
  35. // | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
  36. // | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS|
  37. // |  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED  |
  38. // | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT          |
  39. // | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY|
  40. // | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE          |
  41. // | POSSIBILITY OF SUCH DAMAGE.                                          |
  42. // +----------------------------------------------------------------------+
  43. // | Author: Lukas Smith <smith@backendmedia.com>                         |
  44. // |         Lorenzo Alberton <l.alberton@quipo.it>                       |
  45. // +----------------------------------------------------------------------+
  46. //
  47. // $Id: ibase.php,v 1.28 2005/04/19 12:53:41 lsmith Exp $
  48.  
  49. require_once 'MDB2/Driver/Datatype/Common.php';
  50.  
  51. /**
  52.  * MDB2 Firebird/Interbase driver
  53.  *
  54.  * @package MDB2
  55.  * @category Database
  56.  * @author  Lukas Smith <smith@backendmedia.com>
  57.  * @author  Lorenzo Alberton <l.alberton@quipo.it>
  58.  */
  59. {
  60.     // {{{ convertResult()
  61.  
  62.     /**
  63.      * convert a value to a RDBMS independent MDB2 type
  64.      *
  65.      * @param mixed  $value   value to be converted
  66.      * @param int    $type    constant that specifies which type to convert to
  67.      * @return mixed converted value or a MDB2 error on failure
  68.      * @access public
  69.      */
  70.     function convertResult($value$type)
  71.     {
  72.         if (is_null($value)) {
  73.             return null;
  74.         }
  75.         $db =$GLOBALS['_MDB2_databases'][$this->db_index];
  76.         switch ($type{
  77.         case 'decimal':
  78.             return sprintf('%.'.$db->options['decimal_places'].'f'doubleval($value)/pow(10.0$db->options['decimal_places']));
  79.         case 'timestamp':
  80.             return substr($value0strlen('YYYY-MM-DD HH:MM:SS'));
  81.         default:
  82.             return $this->_baseConvertResult($value$type);
  83.         }
  84.     }
  85.  
  86.     // }}}
  87.     // {{{ _getTypeDeclaration()
  88.  
  89.     /**
  90.      * Obtain DBMS specific SQL code portion needed to declare an text type
  91.      * field to be used in statements like CREATE TABLE.
  92.      *
  93.      * @param array $field  associative array with the name of the properties
  94.      *       of the field being declared as array indexes. Currently, the types
  95.      *       of supported field properties are as follows:
  96.      *
  97.      *       length
  98.      *           Integer value that determines the maximum length of the text
  99.      *           field. If this argument is missing the field should be
  100.      *           declared to have the longest length allowed by the DBMS.
  101.      *
  102.      *       default
  103.      *           Text value to be used as default for this field.
  104.      *
  105.      *       notnull
  106.      *           Boolean flag that indicates whether this field is constrained
  107.      *           to not be set to null.
  108.      * @return string  DBMS specific SQL code portion that should be used to
  109.      *       declare the specified field.
  110.      * @access protected
  111.      */
  112.     function _getTypeDeclaration($field)
  113.     {
  114.         $db =$GLOBALS['_MDB2_databases'][$this->db_index];
  115.         switch ($field['type']{
  116.         case 'text':
  117.             $length (isset($field['length']$field['length'(!PEAR::isError($length $db->options['default_text_field_length']$length : 4000));
  118.             return 'VARCHAR ('.$length.')';
  119.         case 'clob':
  120.             return 'BLOB SUB_TYPE 1';
  121.         case 'blob':
  122.             return 'BLOB SUB_TYPE 0';
  123.         case 'integer':
  124.             return 'INTEGER';
  125.         case 'boolean':
  126.             return 'CHAR (1)';
  127.         case 'date':
  128.             return 'DATE';
  129.         case 'time':
  130.             return 'TIME';
  131.         case 'timestamp':
  132.             return 'TIMESTAMP';
  133.         case 'float':
  134.             return 'DOUBLE PRECISION';
  135.         case 'decimal':
  136.             return 'DECIMAL(18,'.$db->options['decimal_places'].')';
  137.         }
  138.         return '';
  139.     }
  140.  
  141.     // }}}
  142.     // {{{ _getTextDeclaration()
  143.  
  144.     /**
  145.      * Obtain DBMS specific SQL code portion needed to declare a text type
  146.      * field to be used in statements like CREATE TABLE.
  147.      *
  148.      * @param string $name   name the field to be declared.
  149.      * @param array  $field  associative array with the name of the properties
  150.      *       of the field being declared as array indexes. Currently, the types
  151.      *       of supported field properties are as follows:
  152.      *
  153.      *       length
  154.      *           Integer value that determines the maximum length of the text
  155.      *           field. If this argument is missing the field should be
  156.      *           declared to have the longest length allowed by the DBMS.
  157.      *
  158.      *       default
  159.      *           Text value to be used as default for this field.
  160.      *
  161.      *       notnull
  162.      *           Boolean flag that indicates whether this field is constrained
  163.      *           to not be set to null.
  164.      * @return string  DBMS specific SQL code portion that should be used to
  165.      *       declare the specified field.
  166.      * @access protected
  167.      */
  168.     function _getTextDeclaration($name$field)
  169.     {
  170.         $type $this->_getTypeDeclaration($field);
  171.         $default = isset($field['default']' DEFAULT'.
  172.             $this->quote($field['default']'text''';
  173.         $notnull = isset($field['notnull']' NOT NULL' '';
  174.         return $name.' '.$type.$default.$notnull;
  175.     }
  176.  
  177.     // }}}
  178.     // {{{ _getCLOBDeclaration()
  179.  
  180.     /**
  181.      * Obtain DBMS specific SQL code portion needed to declare a character
  182.      * large object type field to be used in statements like CREATE TABLE.
  183.      *
  184.      * @param string $name   name the field to be declared.
  185.      * @param array $field  associative array with the name of the properties
  186.      *       of the field being declared as array indexes. Currently, the types
  187.      *       of supported field properties are as follows:
  188.      *
  189.      *       length
  190.      *           Integer value that determines the maximum length of the large
  191.      *           object field. If this argument is missing the field should be
  192.      *           declared to have the longest length allowed by the DBMS.
  193.      *
  194.      *       notnull
  195.      *           Boolean flag that indicates whether this field is constrained
  196.      *           to not be set to null.
  197.      * @return string  DBMS specific SQL code portion that should be used to
  198.      *       declare the specified field.
  199.      * @access protected
  200.      */
  201.     function _getCLOBDeclaration($name$field)
  202.     {
  203.         $notnull = isset($field['notnull']' NOT NULL' '';
  204.         return $name.' '.$this->_getTypeDeclaration($field).$notnull;
  205.     }
  206.  
  207.     // }}}
  208.     // {{{ _getBLOBDeclaration()
  209.  
  210.     /**
  211.      * Obtain DBMS specific SQL code portion needed to declare a binary large
  212.      * object type field to be used in statements like CREATE TABLE.
  213.      *
  214.      * @param string $name   name the field to be declared.
  215.      * @param array $field  associative array with the name of the properties
  216.      *       of the field being declared as array indexes. Currently, the types
  217.      *       of supported field properties are as follows:
  218.      *
  219.      *       length
  220.      *           Integer value that determines the maximum length of the large
  221.      *           object field. If this argument is missing the field should be
  222.      *           declared to have the longest length allowed by the DBMS.
  223.      *
  224.      *       notnull
  225.      *           Boolean flag that indicates whether this field is constrained
  226.      *           to not be set to null.
  227.      * @return string  DBMS specific SQL code portion that should be used to
  228.      *       declare the specified field.
  229.      * @access protected
  230.      */
  231.     function _getBLOBDeclaration($name$field)
  232.     {
  233.         $notnull = isset($field['notnull']' NOT NULL' '';
  234.         return $name.' '.$this->_getTypeDeclaration($field).$notnull;
  235.     }
  236.  
  237.     // }}}
  238.     // {{{ _getDateDeclaration()
  239.  
  240.     /**
  241.      * Obtain DBMS specific SQL code portion needed to declare a date type
  242.      * field to be used in statements like CREATE TABLE.
  243.      *
  244.      * @param string $name   name the field to be declared.
  245.      * @param array $field  associative array with the name of the properties
  246.      *       of the field being declared as array indexes. Currently, the types
  247.      *       of supported field properties are as follows:
  248.      *
  249.      *       default
  250.      *           Date value to be used as default for this field.
  251.      *
  252.      *       notnull
  253.      *           Boolean flag that indicates whether this field is constrained
  254.      *           to not be set to null.
  255.      * @return string  DBMS specific SQL code portion that should be used to
  256.      *       declare the specified field.
  257.      * @access protected
  258.      */
  259.     function _getDateDeclaration($name$field)
  260.     {
  261.         $default = isset($field['default']' DEFAULT '.
  262.             $this->quote($field['default']'date''';
  263.         $notnull = isset($field['notnull']' NOT NULL' '';
  264.         return $name.' '.$this->_getTypeDeclaration($field).$default.$notnull;
  265.     }
  266.  
  267.     // }}}
  268.     // {{{ _getTimeDeclaration()
  269.  
  270.     /**
  271.      * Obtain DBMS specific SQL code portion needed to declare a time
  272.      * field to be used in statements like CREATE TABLE.
  273.      *
  274.      * @param string $name   name the field to be declared.
  275.      * @param array $field  associative array with the name of the properties
  276.      *       of the field being declared as array indexes. Currently, the types
  277.      *       of supported field properties are as follows:
  278.      *
  279.      *       default
  280.      *           Time value to be used as default for this field.
  281.      *
  282.      *       notnull
  283.      *           Boolean flag that indicates whether this field is constrained
  284.      *           to not be set to null.
  285.      * @return string  DBMS specific SQL code portion that should be used to
  286.      *       declare the specified field.
  287.      * @access protected
  288.      */
  289.     function _getTimeDeclaration($name$field)
  290.     {
  291.         $default = isset($field['default']' DEFAULT '.
  292.             $this->quote($field['default']'time''';
  293.         $notnull = isset($field['notnull']' NOT NULL' '';
  294.         return $name.' '.$this->_getTypeDeclaration($field).$default.$notnull;
  295.     }
  296.  
  297.     // }}}
  298.     // {{{ _getTimestampDeclaration()
  299.  
  300.     /**
  301.      * Obtain DBMS specific SQL code portion needed to declare a timestamp
  302.      * field to be used in statements like CREATE TABLE.
  303.      *
  304.      * @param string  $name   name the field to be declared.
  305.      * @param array   $field  associative array with the name of the properties
  306.      *        of the field being declared as array indexes. Currently, the types
  307.      *        of supported field properties are as follows:
  308.      *
  309.      *        default
  310.      *            Timestamp value to be used as default for this field.
  311.      *
  312.      *        notnull
  313.      *            Boolean flag that indicates whether this field is constrained
  314.      *            to not be set to null.
  315.      * @return string  DBMS specific SQL code portion that should be used to
  316.      *                  declare the specified field.
  317.      * @access protected
  318.      */
  319.     function _getTimestampDeclaration($name$field)
  320.     {
  321.         $default = isset($field['default']' DEFAULT '.
  322.             $this->quote($field['default']'timestamp''';
  323.         $notnull = isset($field['notnull']' NOT NULL' '';
  324.         return $name.' '.$this->_getTypeDeclaration($field).$default.$notnull;
  325.     }
  326.  
  327.     // }}}
  328.     // {{{ _getFloatDeclaration()
  329.  
  330.     /**
  331.      * Obtain DBMS specific SQL code portion needed to declare a float type
  332.      * field to be used in statements like CREATE TABLE.
  333.      *
  334.      * @param string $name   name the field to be declared.
  335.      * @param array $field  associative array with the name of the properties
  336.      *       of the field being declared as array indexes. Currently, the types
  337.      *       of supported field properties are as follows:
  338.      *
  339.      *       default
  340.      *           Float value to be used as default for this field.
  341.      *
  342.      *       notnull
  343.      *           Boolean flag that indicates whether this field is constrained
  344.      *           to not be set to null.
  345.      * @return string  DBMS specific SQL code portion that should be used to
  346.      *       declare the specified field.
  347.      * @access protected
  348.      */
  349.     function _getFloatDeclaration($name$field)
  350.     {
  351.         $default = isset($field['default']' DEFAULT '.
  352.             $this->quote($field['default']'float''';
  353.         $notnull = isset($field['notnull']' NOT NULL' '';
  354.         return $name.' '.$this->_getTypeDeclaration($field).$default.$notnull;
  355.     }
  356.  
  357.     // }}}
  358.     // {{{ _getDecimalDeclaration()
  359.  
  360.     /**
  361.      * Obtain DBMS specific SQL code portion needed to declare a decimal type
  362.      * field to be used in statements like CREATE TABLE.
  363.      *
  364.      * @param string $name   name the field to be declared.
  365.      * @param array $field  associative array with the name of the properties
  366.      *       of the field being declared as array indexes. Currently, the types
  367.      *       of supported field properties are as follows:
  368.      *
  369.      *       default
  370.      *           Decimal value to be used as default for this field.
  371.      *
  372.      *       notnull
  373.      *           Boolean flag that indicates whether this field is constrained
  374.      *           to not be set to null.
  375.      * @return string  DBMS specific SQL code portion that should be used to
  376.      *       declare the specified field.
  377.      * @access protected
  378.      */
  379.     function _getDecimalDeclaration($name$field)
  380.     {
  381.         $default = isset($field['default']' DEFAULT '.
  382.             $this->quote($field['default']'decimal''';
  383.         $notnull = isset($field['notnull']' NOT NULL' '';
  384.         return $name.' '.$this->_getTypeDeclaration($field).$default.$notnull;
  385.     }
  386.  
  387.     // }}}
  388.     // {{{ _quoteLOB()
  389.  
  390.     /**
  391.      * Convert a text value into a DBMS specific format that is suitable to
  392.      * compose query statements.
  393.      *
  394.      * @param  $value 
  395.      * @return string text string that represents the given argument value in
  396.      *       a DBMS specific format.
  397.      * @access protected
  398.      */
  399.     function _quoteLOB($value)
  400.     {
  401.         $db =$GLOBALS['_MDB2_databases'][$this->db_index];
  402.         if (PEAR::isError($connect $db->connect())) {
  403.             return $connect;
  404.         }
  405.         $close = true;
  406.         if (is_resource($value)) {
  407.             $close = false;
  408.         elseif (preg_match('/^(\w+:\/\/)(.*)$/'$value$match)) {
  409.             if ($match[1== 'file://'{
  410.                 $value $match[2];
  411.             }
  412.             $value @fopen($value'r');
  413.         else {
  414.             $fp @tmpfile();
  415.             @fwrite($fp$value);
  416.             @rewind($fp);
  417.             $value $fp;
  418.         }
  419.         if ($db->in_transaction{
  420.             $value @ibase_blob_import($db->transaction_id$value);
  421.         else {
  422.             $value @ibase_blob_import($db->connection$value);
  423.         }
  424.         if ($close{
  425.             @fclose($value);
  426.         }
  427.         return $value;
  428.     }
  429.  
  430.     // }}}
  431.     // {{{ _quoteCLOB()
  432.  
  433.     /**
  434.      * Convert a text value into a DBMS specific format that is suitable to
  435.      * compose query statements.
  436.      *
  437.      * @param  $value 
  438.      * @return string text string that represents the given argument value in
  439.      *       a DBMS specific format.
  440.      * @access protected
  441.      */
  442.     function _quoteCLOB($value)
  443.     {
  444.         return $this->_quoteLOB($value);
  445.     }
  446.  
  447.     // }}}
  448.     // {{{ _quoteBLOB()
  449.  
  450.     /**
  451.      * Convert a text value into a DBMS specific format that is suitable to
  452.      * compose query statements.
  453.      *
  454.      * @param  $value 
  455.      * @return string text string that represents the given argument value in
  456.      *       a DBMS specific format.
  457.      * @access protected
  458.      */
  459.     function _quoteBLOB($value)
  460.     {
  461.         return $this->_quoteLOB($value);
  462.     }
  463.     
  464.     // }}}
  465.     // {{{ _quoteBoolean()
  466.  
  467.     /**
  468.      * Convert a text value into a DBMS specific format that is suitable to
  469.      * compose query statements.
  470.      *
  471.      * @param string $value text string value that is intended to be converted.
  472.      * @return string text string that represents the given argument value in
  473.      *        a DBMS specific format.
  474.      * @access protected
  475.      */
  476.     function _quoteBoolean($value)
  477.     {
  478.         return ($value "'Y'" "'N'");
  479.     }
  480.  
  481.     // }}}
  482.     // {{{ _quoteDecimal()
  483.  
  484.     /**
  485.      * Convert a text value into a DBMS specific format that is suitable to
  486.      * compose query statements.
  487.      *
  488.      * @param string $value text string value that is intended to be converted.
  489.      * @return string text string that represents the given argument value in
  490.      *       a DBMS specific format.
  491.      * @access protected
  492.      */
  493.     function _quoteDecimal($value)
  494.     {
  495.         $db =$GLOBALS['_MDB2_databases'][$this->db_index];
  496.         return (strval(round($value*pow(10.0$db->options['decimal_places']))));
  497.     }
  498.  
  499.     // }}}
  500.     // {{{ _retrieveLOB()
  501.  
  502.     /**
  503.      * retrieve LOB from the database
  504.      *
  505.      * @param int $lob handle to a lob created by the createLob() function
  506.      * @return mixed MDB2_OK on success, a MDB2 error on failure
  507.      * @access protected
  508.      */
  509.     function _retrieveLOB($lob)
  510.     {
  511.         $db =$GLOBALS['_MDB2_databases'][$this->db_index];
  512.  
  513.         if (!isset($db->lobs[$lob])) {
  514.             return $db->raiseError(MDB2_ERROR_INVALIDnullnull,
  515.                 '_retrieveLOB: it was not specified a valid lob');
  516.         }
  517.  
  518.         if (!isset($db->lobs[$lob]['handle'])) {
  519.             $db->lobs[$lob]['handle'=
  520.                 @ibase_blob_open($db->lobs[$lob]['value']);
  521.             if (!$db->lobs[$lob]['handle']{
  522.                 unset($db->lobs[$lob]['value']);
  523.                 return $db->raiseError(MDB2_ERRORnullnull,
  524.                     '_retrieveLOB: Could not open fetched large object field' @ibase_errmsg());
  525.             }
  526.         }
  527.         return MDB2_OK;
  528.     }
  529.  
  530.     // }}}
  531.     // {{{ _endOfResultLOB()
  532.  
  533.     /**
  534.      * Determine whether it was reached the end of the large object and
  535.      * therefore there is no more data to be read for the its input stream.
  536.      *
  537.      * @param int    $lob handle to a lob created by the createLOB() function
  538.      * @return mixed true or false on success, a MDB2 error on failure
  539.      * @access protected
  540.      */
  541.     function _endOfResultLOB($lob)
  542.     {
  543.         $db =$GLOBALS['_MDB2_databases'][$this->db_index];
  544.         $lobresult $this->_retrieveLOB($lob);
  545.         if (PEAR::isError($lobresult)) {
  546.             return $lobresult;
  547.         }
  548.         return isset($db->lobs[$lob]['EndOfLOB']);
  549.     }
  550.  
  551.     // }}}
  552.     // {{{ _readResultLOB()
  553.  
  554.     /**
  555.      * Read data from large object input stream.
  556.      *
  557.      * @param int $lob handle to a lob created by the createLob() function
  558.      * @param blob $data reference to a variable that will hold data to be
  559.      *       read from the large object input stream
  560.      * @param int $length integer value that indicates the largest ammount of
  561.      *       data to be read from the large object input stream.
  562.      * @return mixed length on success, a MDB2 error on failure
  563.      * @access protected
  564.      */
  565.     function _readResultLOB($lob&$data$length)
  566.     {
  567.         $db =$GLOBALS['_MDB2_databases'][$this->db_index];
  568.         if (PEAR::isError($lobresult $this->_retrieveLOB($lob))) {
  569.             return $lobresult;
  570.         }
  571.         $data @ibase_blob_get($db->lobs[$lob]['handle']$length);
  572.         if (!is_string($data)) {
  573.             $db->raiseError(MDB2_ERRORnullnull,
  574.                 'Read Result LOB: ' @ibase_errmsg());
  575.         }
  576.         if (($length strlen($data)) == 0{
  577.             $db->lobs[$lob]['EndOfLOB'= 1;
  578.         }
  579.         return $length;
  580.     }
  581.  
  582.     // }}}
  583.     // {{{ _destroyResultLOB()
  584.  
  585.     /**
  586.      * Free any resources allocated during the lifetime of the large object
  587.      * handler object.
  588.      *
  589.      * @param int $lob handle to a lob created by the createLob() function
  590.      * @access protected
  591.      */
  592.     function _destroyResultLOB($lob)
  593.     {
  594.         $db =$GLOBALS['_MDB2_databases'][$this->db_index];
  595.         if (isset($db->lobs[$lob])) {
  596.             if (isset($db->lobs[$lob]['value'])) {
  597.                @ibase_blob_close($db->lobs[$lob]['handle']);
  598.             }
  599.             $db->lobs[$lob'';
  600.         }
  601.     }
  602.  
  603.     // }}}
  604.     // {{{ mapNativeDatatype()
  605.  
  606.     /**
  607.      * Maps a native array description of a field to a MDB2 datatype and length
  608.      *
  609.      * @param array  $field native field description
  610.      * @return array containing the various possible types and the length
  611.      * @access public
  612.      */
  613.     function mapNativeDatatype($field)
  614.     {
  615.         $db =$GLOBALS['_MDB2_databases'][$this->db_index];
  616.         $db_type preg_replace('/\d/',''strtolower($field['typname']) );
  617.         $length $field['attlen'];
  618.         if ($length == '-1'{
  619.             $length $field['atttypmod']-4;
  620.         }
  621.         if ((int)$length <= 0{
  622.             $length = null;
  623.         }
  624.         $type = array();
  625.         switch ($db_type{
  626.         case 'smallint':
  627.         case 'integer':
  628.             $type['integer';
  629.             if ($length == '1'{
  630.                 $type['boolean';
  631.             }
  632.             break;
  633.         case 'char':
  634.         case 'varchar':
  635.             $type['text';
  636.             if ($length == '1'{
  637.                 $type['boolean';
  638.             }
  639.             break;
  640.         case 'date':
  641.             $type['date';
  642.             $length = null;
  643.             break;
  644.         case 'timestamp':
  645.             $type['timestamp';
  646.             $length = null;
  647.             break;
  648.         case 'time':
  649.             $type['time';
  650.             $length = null;
  651.             break;
  652.         case 'float':
  653.         case 'double precision':
  654.             $type['float';
  655.             break;
  656.         case 'decimal':
  657.         case 'numeric':
  658.             $type['decimal';
  659.             break;
  660.         case 'blob':
  661.             $type['blob';
  662.             $length = null;
  663.             break;
  664.         default:
  665.             return $db->raiseError(MDB2_ERRORnullnull,
  666.                 'getTableFieldDefinition: unknown database attribute type');
  667.         }
  668.  
  669.         return array($type$length);
  670.     }
  671.     
  672.     // }}}
  673. }
  674. ?>

Documentation generated on Mon, 11 Mar 2019 14:20:17 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.