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 Version 4                                                        |
  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. // +----------------------------------------------------------------------+
  45. //
  46. // $Id: ibase.php,v 1.7 2004/04/09 10:41:21 lsmith Exp $
  47. //
  48.  
  49. require_once 'MDB2/Driver/Datatype/Common.php';
  50.  
  51. /**
  52.  * MDB2 MySQL driver
  53.  *
  54.  * @package MDB2
  55.  * @category Database
  56.  * @author  Lukas Smith <smith@backendmedia.com>
  57.  */
  58. {
  59.     // }}}
  60.     // {{{ constructor
  61.  
  62.     /**
  63.      * Constructor
  64.      */
  65.     function MDB2_Driver_Datatype_ibase($db_index)
  66.     {
  67.         $this->MDB2_Driver_Datatype_Common($db_index);
  68.     }
  69.  
  70.     // }}}
  71.     // {{{ convertResult()
  72.  
  73.     /**
  74.      * convert a value to a RDBMS indepdenant MDB2 type
  75.      *
  76.      * @param mixed  $value   value to be converted
  77.      * @param int    $type    constant that specifies which type to convert to
  78.      * @return mixed converted value
  79.      * @access public
  80.      */
  81.     function convertResult($value$type)
  82.     {
  83.         $db =$GLOBALS['_MDB2_databases'][$this->db_index];
  84.         switch ($type{
  85.             case MDB2_TYPE_DECIMAL:
  86.                 return sprintf('%.'.$db->options['decimal_places'].'f'doubleval($value)/pow(10.0$db->options['decimal_places']));
  87.             case MDB2_TYPE_TIMESTAMP:
  88.                 return substr($value0strlen('YYYY-MM-DD HH:MM:SS'));
  89.             default:
  90.                 return $this->_baseConvertResult($value$type);
  91.         }
  92.     }
  93.  
  94.     // }}}
  95.     // {{{ getTypeDeclaration()
  96.  
  97.     /**
  98.      * Obtain DBMS specific SQL code portion needed to declare an text type
  99.      * field to be used in statements like CREATE TABLE.
  100.      *
  101.      * @param string $field  associative array with the name of the properties
  102.      *       of the field being declared as array indexes. Currently, the types
  103.      *       of supported field properties are as follows:
  104.      *
  105.      *       length
  106.      *           Integer value that determines the maximum length of the text
  107.      *           field. If this argument is missing the field should be
  108.      *           declared to have the longest length allowed by the DBMS.
  109.      *
  110.      *       default
  111.      *           Text value to be used as default for this field.
  112.      *
  113.      *       notnull
  114.      *           Boolean flag that indicates whether this field is constrained
  115.      *           to not be set to null.
  116.      * @return string  DBMS specific SQL code portion that should be used to
  117.      *       declare the specified field.
  118.      * @access public
  119.      */
  120.     function getTypeDeclaration($field)
  121.     {
  122.         $db =$GLOBALS['_MDB2_databases'][$this->db_index];
  123.         switch ($field['type'])
  124.         {
  125.             case 'text':
  126.                 $length (isset($field['length']$field['length'(!MDB2::isError($length $db->options['default_text_field_length']$length : 4000));
  127.                 return 'VARCHAR ('.$length.')';
  128.             case 'clob':
  129.                 return 'BLOB SUB_TYPE 1';
  130.             case 'blob':
  131.                 return 'BLOB SUB_TYPE 0';
  132.             case 'integer':
  133.                 return 'INTEGER';
  134.             case 'boolean':
  135.                 return 'CHAR (1)';
  136.             case 'date':
  137.                 return 'DATE';
  138.             case 'time':
  139.                 return 'TIME';
  140.             case 'timestamp':
  141.                 return 'TIMESTAMP';
  142.             case 'float':
  143.                 return 'DOUBLE PRECISION';
  144.             case 'decimal':
  145.                 return 'DECIMAL(18,'.$db->options['decimal_places'].')';
  146.         }
  147.         return '';
  148.     }
  149.  
  150.     // }}}
  151.     // {{{ getTextDeclaration()
  152.  
  153.     /**
  154.      * Obtain DBMS specific SQL code portion needed to declare an text type
  155.      * field to be used in statements like CREATE TABLE.
  156.      *
  157.      * @param string $name   name the field to be declared.
  158.      * @param string $field  associative array with the name of the properties
  159.      *       of the field being declared as array indexes. Currently, the types
  160.      *       of supported field properties are as follows:
  161.      *
  162.      *       length
  163.      *           Integer value that determines the maximum length of the text
  164.      *           field. If this argument is missing the field should be
  165.      *           declared to have the longest length allowed by the DBMS.
  166.      *
  167.      *       default
  168.      *           Text value to be used as default for this field.
  169.      *
  170.      *       notnull
  171.      *           Boolean flag that indicates whether this field is constrained
  172.      *           to not be set to null.
  173.      * @return string  DBMS specific SQL code portion that should be used to
  174.      *       declare the specified field.
  175.      * @access public
  176.      */
  177.     function getTextDeclaration($name$field)
  178.     {
  179.         $db =$GLOBALS['_MDB2_databases'][$this->db_index];
  180.         $type $this->getTypeDeclaration($field);
  181.         $default = isset($field['default']' DEFAULT TIME'.
  182.             $this->quoteText($field['default']'';
  183.         $notnull = isset($field['notnull']' NOT NULL' '';
  184.         return $name.' '.$type.$default.$notnull;
  185.     }
  186.  
  187.     // }}}
  188.     // {{{ getCLOBDeclaration()
  189.  
  190.     /**
  191.      * Obtain DBMS specific SQL code portion needed to declare an character
  192.      * large object type field to be used in statements like CREATE TABLE.
  193.      *
  194.      * @param string $name   name the field to be declared.
  195.      * @param string $field  associative array with the name of the properties
  196.      *       of the field being declared as array indexes. Currently, the types
  197.      *       of supported field properties are as follows:
  198.      *
  199.      *       length
  200.      *           Integer value that determines the maximum length of the large
  201.      *           object field. If this argument is missing the field should be
  202.      *           declared to have the longest length allowed by the DBMS.
  203.      *
  204.      *       notnull
  205.      *           Boolean flag that indicates whether this field is constrained
  206.      *           to not be set to null.
  207.      * @return string  DBMS specific SQL code portion that should be used to
  208.      *       declare the specified field.
  209.      * @access public
  210.      */
  211.     function getCLOBDeclaration($name$field)
  212.     {
  213.         $db =$GLOBALS['_MDB2_databases'][$this->db_index];
  214.         $notnull = isset($field['notnull']' NOT NULL' '';
  215.         return $name.' '.$this->getTypeDeclaration($field).$notnull;
  216.     }
  217.  
  218.     // }}}
  219.     // {{{ getBLOBDeclaration()
  220.  
  221.     /**
  222.      * Obtain DBMS specific SQL code portion needed to declare an binary large
  223.      * object type field to be used in statements like CREATE TABLE.
  224.      *
  225.      * @param string $name   name the field to be declared.
  226.      * @param string $field  associative array with the name of the properties
  227.      *       of the field being declared as array indexes. Currently, the types
  228.      *       of supported field properties are as follows:
  229.      *
  230.      *       length
  231.      *           Integer value that determines the maximum length of the large
  232.      *           object field. If this argument is missing the field should be
  233.      *           declared to have the longest length allowed by the DBMS.
  234.      *
  235.      *       notnull
  236.      *           Boolean flag that indicates whether this field is constrained
  237.      *           to not be set to null.
  238.      * @return string  DBMS specific SQL code portion that should be used to
  239.      *       declare the specified field.
  240.      * @access public
  241.      */
  242.     function getBLOBDeclaration($name$field)
  243.     {
  244.         $db =$GLOBALS['_MDB2_databases'][$this->db_index];
  245.         $notnull = isset($field['notnull']' NOT NULL' '';
  246.         return $name.' '.$this->getTypeDeclaration($field).$notnull;
  247.     }
  248.  
  249.     // }}}
  250.     // {{{ getDateDeclaration()
  251.  
  252.     /**
  253.      * Obtain DBMS specific SQL code portion needed to declare a date type
  254.      * field to be used in statements like CREATE TABLE.
  255.      *
  256.      * @param string $name   name the field to be declared.
  257.      * @param string $field  associative array with the name of the properties
  258.      *       of the field being declared as array indexes. Currently, the types
  259.      *       of supported field properties are as follows:
  260.      *
  261.      *       default
  262.      *           Date value to be used as default for this field.
  263.      *
  264.      *       notnull
  265.      *           Boolean flag that indicates whether this field is constrained
  266.      *           to not be set to null.
  267.      * @return string  DBMS specific SQL code portion that should be used to
  268.      *       declare the specified field.
  269.      * @access public
  270.      */
  271.     function getDateDeclaration($name$field)
  272.     {
  273.         $db =$GLOBALS['_MDB2_databases'][$this->db_index];
  274.         $default = isset($field['default']' DEFAULT '.
  275.             $this->quoteDate($field['default']'';
  276.         $notnull = isset($field['notnull']' NOT NULL' '';
  277.         return $name.' '.$this->getTypeDeclaration($field).$default.$notnull;
  278.     }
  279.  
  280.     // }}}
  281.     // {{{ getTimestampDeclaration()
  282.  
  283.     /**
  284.      * Obtain DBMS specific SQL code portion needed to declare an timestamp
  285.      * type field to be used in statements like CREATE TABLE.
  286.      *
  287.      * @param string  $name   name the field to be declared.
  288.      * @param string  $field  associative array with the name of the properties
  289.      *                         of the field being declared as array indexes.
  290.      *                         Currently, the types of supported field
  291.      *                         properties are as follows:
  292.      *
  293.      *                        default
  294.      *                         Time stamp value to be used as default for this
  295.      *                         field.
  296.      *
  297.      *                        notnull
  298.      *                         Boolean flag that indicates whether this field is
  299.      *                         constrained to not be set to null.
  300.      * @return string  DBMS specific SQL code portion that should be used to
  301.      *                  declare the specified field.
  302.      * @access public
  303.      */
  304.     function getTimestampDeclaration($name$field)
  305.     {
  306.         $db =$GLOBALS['_MDB2_databases'][$this->db_index];
  307.         $default = isset($field['default']' DEFAULT '.
  308.             $this->quoteTimestamp($field['default']'';
  309.         $notnull = isset($field['notnull']' NOT NULL' '';
  310.         return $name.' '.$this->getTypeDeclaration($field).$default.$notnull;
  311.     }
  312.  
  313.     // }}}
  314.     // {{{ getTimeDeclaration()
  315.  
  316.     /**
  317.      * Obtain DBMS specific SQL code portion needed to declare a time
  318.      * field to be used in statements like CREATE TABLE.
  319.      *
  320.      * @param string $name   name the field to be declared.
  321.      * @param string $field  associative array with the name of the properties
  322.      *       of the field being declared as array indexes. Currently, the types
  323.      *       of supported field properties are as follows:
  324.      *
  325.      *       default
  326.      *           Time value to be used as default for this field.
  327.      *
  328.      *       notnull
  329.      *           Boolean flag that indicates whether this field is constrained
  330.      *           to not be set to null.
  331.      * @return string  DBMS specific SQL code portion that should be used to
  332.      *       declare the specified field.
  333.      * @access public
  334.      */
  335.     function getTimeDeclaration($name$field)
  336.     {
  337.         $db =$GLOBALS['_MDB2_databases'][$this->db_index];
  338.         $default = isset($field['default']' DEFAULT '.
  339.             $this->quoteTime($field['default']'';
  340.         $notnull = isset($field['notnull']' NOT NULL' '';
  341.         return $name.' '.$this->getTypeDeclaration($field).$default.$notnull;
  342.     }
  343.  
  344.     // }}}
  345.     // {{{ getFloatDeclaration()
  346.  
  347.     /**
  348.      * Obtain DBMS specific SQL code portion needed to declare a float type
  349.      * field to be used in statements like CREATE TABLE.
  350.      *
  351.      * @param string $name   name the field to be declared.
  352.      * @param string $field  associative array with the name of the properties
  353.      *       of the field being declared as array indexes. Currently, the types
  354.      *       of supported field properties are as follows:
  355.      *
  356.      *       default
  357.      *           Float value to be used as default for this field.
  358.      *
  359.      *       notnull
  360.      *           Boolean flag that indicates whether this field is constrained
  361.      *           to not be set to null.
  362.      * @return string  DBMS specific SQL code portion that should be used to
  363.      *       declare the specified field.
  364.      * @access public
  365.      */
  366.     function getFloatDeclaration($name$field)
  367.     {
  368.         $db =$GLOBALS['_MDB2_databases'][$this->db_index];
  369.         $default = isset($field['default']' DEFAULT '.
  370.             $this->quoteFloat($field['default']'';
  371.         $notnull = isset($field['notnull']' NOT NULL' '';
  372.         return $name.' '.$this->getTypeDeclaration($field).$default.$notnull;
  373.     }
  374.  
  375.     // }}}
  376.     // {{{ getDecimalDeclaration()
  377.  
  378.     /**
  379.      * Obtain DBMS specific SQL code portion needed to declare a decimal type
  380.      * field to be used in statements like CREATE TABLE.
  381.      *
  382.      * @param string $name   name the field to be declared.
  383.      * @param string $field  associative array with the name of the properties
  384.      *       of the field being declared as array indexes. Currently, the types
  385.      *       of supported field properties are as follows:
  386.      *
  387.      *       default
  388.      *           Decimal value to be used as default for this field.
  389.      *
  390.      *       notnull
  391.      *           Boolean flag that indicates whether this field is constrained
  392.      *           to not be set to null.
  393.      * @return string  DBMS specific SQL code portion that should be used to
  394.      *       declare the specified field.
  395.      * @access public
  396.      */
  397.     function getDecimalDeclaration($name$field)
  398.     {
  399.  
  400.         $db =$GLOBALS['_MDB2_databases'][$this->db_index];
  401.         $default = isset($field['default']' DEFAULT '.
  402.             $this->quoteDecimal($field['default']'';
  403.         $notnull = isset($field['notnull']' NOT NULL' '';
  404.         return $name.' '.$this->getTypeDeclaration($field).$default.$notnull;
  405.     }
  406.  
  407.     // }}}
  408.     // {{{ _quoteLOB()
  409.  
  410.     /**
  411.      * Convert a text value into a DBMS specific format that is suitable to
  412.      * compose query statements.
  413.      *
  414.      * @param resource  $prepared_query query handle from prepare()
  415.      * @param           $parameter 
  416.      * @param           $lob 
  417.      * @return string text string that represents the given argument value in
  418.      *       a DBMS specific format.
  419.      * @access private
  420.      */
  421.     function _quoteLOB($lob)
  422.     {
  423.         $db =$GLOBALS['_MDB2_databases'][$this->db_index];
  424.         if (MDB2::isError($connect $db->connect())) {
  425.             return $connect;
  426.         }
  427.         $prepared_query $GLOBALS['_MDB2_LOBs'][$lob]->prepared_query;
  428.         $parameter $GLOBALS['_MDB2_LOBs'][$lob]->parameter;
  429.         $value   '';  // DEAL WITH ME
  430.         if (!$db->transaction_id = @ibase_trans(IBASE_COMMITTED$db->connection)) {
  431.             return $db->raiseError(MDB2_ERRORnullnull,
  432.                 'Could not start a new transaction: '.ibase_errmsg());
  433.         }
  434.  
  435.         if (($lo @ibase_blob_create($db->auto_commit ? $db->connection : $db->transaction_id))) {
  436.             while (!$this->endOfLOB($lob)) {
  437.                 $result $this->readLOB($lob$data$db->options['lob_buffer_length']);
  438.                 if (MDB2::isError($result)) {
  439.                     break;
  440.                 }
  441.                 if (@ibase_blob_add($lo$data=== false{
  442.                     $result $db->raiseError(MDB2_ERRORnullnull,
  443.                         'Could not add data to a large object: '.ibase_errmsg());
  444.                     break;
  445.                 }
  446.             }
  447.             if (MDB2::isError($result)) {
  448.                 @ibase_blob_cancel($lo);
  449.             else {
  450.                 $value @ibase_blob_close($lo);
  451.             }
  452.         else {
  453.             $result $db->raiseError();
  454.         }
  455.         if (!isset($db->query_parameters[$prepared_query])) {
  456.             $db->query_parameters[$prepared_query]       = array(0'');
  457.             $db->query_parameter_values[$prepared_query= array();
  458.         }
  459.         $query_parameter count($db->query_parameters[$prepared_query]);
  460.         $db->query_parameters[$prepared_query][$query_parameter$value;
  461.         $db->query_parameter_values[$prepared_query][$parameter$query_parameter;
  462.         $value '?';
  463.  
  464.         if (!$db->auto_commit{
  465.             $db->commit();
  466.         }
  467.         return $value;
  468.     }
  469.  
  470.     // }}}
  471.     // {{{ quoteCLOB()
  472.  
  473.     /**
  474.      * Convert a text value into a DBMS specific format that is suitable to
  475.      * compose query statements.
  476.      *
  477.      * @param           $clob 
  478.      * @return string text string that represents the given argument value in
  479.      *       a DBMS specific format.
  480.      * @access public
  481.      */
  482.     function quoteCLOB($clob)
  483.     {
  484.         $db =$GLOBALS['_MDB2_databases'][$this->db_index];
  485.         if ($clob === null{
  486.             return 'NULL';
  487.         }
  488.         return $this->_quoteLOB($clob);
  489.     }
  490.  
  491.     // }}}
  492.     // {{{ quoteBLOB()
  493.  
  494.     /**
  495.      * Convert a text value into a DBMS specific format that is suitable to
  496.      * compose query statements.
  497.      *
  498.      * @param           $blob 
  499.      * @return string text string that represents the given argument value in
  500.      *       a DBMS specific format.
  501.      * @access public
  502.      */
  503.     function quoteBLOB($blob)
  504.     {
  505.         $db =$GLOBALS['_MDB2_databases'][$this->db_index];
  506.         if ($blob === null{
  507.             return 'NULL';
  508.         }
  509.         return $this->_quoteLOB($blob);
  510.     }
  511.  
  512.     // }}}
  513.     // {{{ quoteFloat()
  514.  
  515.     /**
  516.      * Convert a text value into a DBMS specific format that is suitable to
  517.      * compose query statements.
  518.      *
  519.      * @param string $value text string value that is intended to be converted.
  520.      * @return string text string that represents the given argument value in
  521.      *       a DBMS specific format.
  522.      * @access public
  523.      */
  524.     function quoteFloat($value)
  525.     {
  526.         $db =$GLOBALS['_MDB2_databases'][$this->db_index];
  527.         return (($value === null'NULL' $value);
  528.     }
  529.  
  530.     // }}}
  531.     // {{{ quoteDecimal()
  532.  
  533.     /**
  534.      * Convert a text value into a DBMS specific format that is suitable to
  535.      * compose query statements.
  536.      *
  537.      * @param string $value text string value that is intended to be converted.
  538.      * @return string text string that represents the given argument value in
  539.      *       a DBMS specific format.
  540.      * @access public
  541.      */
  542.     function quoteDecimal($value)
  543.     {
  544.         $db =$GLOBALS['_MDB2_databases'][$this->db_index];
  545.         return (($value === null'NULL' strval(round($value*pow(10.0$db->options['decimal_places']))));
  546.     }
  547.  
  548.     // }}}
  549.     // {{{ _retrieveLOB()
  550.  
  551.     /**
  552.      * fetch a lob value from a result set
  553.      *
  554.      * @param int $lob handle to a lob created by the createLob() function
  555.      * @return mixed MDB2_OK on success, a MDB error on failure
  556.      * @access private
  557.      */
  558.     function _retrieveLOB($lob)
  559.     {
  560.         $db =$GLOBALS['_MDB2_databases'][$this->db_index];
  561.  
  562.         if (!isset($db->lobs[$lob])) {
  563.             return($db->raiseError(MDB2_ERRORNULLNULL,
  564.                 'Retrieve LOB: it was not specified a valid lob'));
  565.         }
  566.  
  567.         if (!isset($db->lobs[$lob]['handle'])) {
  568.             $db->lobs[$lob]['handle'=
  569.                 @ibase_blob_open($db->lobs[$lob]['value']);
  570.             if (!$db->lobs[$lob]['handle']{
  571.                 unset($db->lobs[$lob]['value']);
  572.                 return($db->raiseError(MDB2_ERRORNULLNULL,
  573.                     'Retrieve LOB: Could not open fetched large object field' @ibase_errmsg()));
  574.             }
  575.         }
  576.  
  577.         return MDB2_OK;
  578.     }
  579.  
  580.     // }}}
  581.     // {{{ _endOfResultLOB()
  582.  
  583.     /**
  584.      * Determine whether it was reached the end of the large object and
  585.      * therefore there is no more data to be read for the its input stream.
  586.      *
  587.      * @param int    $lob handle to a lob created by the createLOB() function
  588.      * @return mixed true or false on success, a MDB2 error on failure
  589.      * @access private
  590.      */
  591.     function _endOfResultLOB($lob)
  592.     {
  593.         $db =$GLOBALS['_MDB2_databases'][$this->db_index];
  594.         $lobresult $this->_retrieveLOB($lob);
  595.         if (MDB2::isError($lobresult)) {
  596.             return $lobresult;
  597.         }
  598.         return isset($db->lobs[$lob]['EndOfLOB']);
  599.     }
  600.  
  601.     // }}}
  602.     // {{{ _readResultLOB()
  603.  
  604.     /**
  605.      * Read data from large object input stream.
  606.      *
  607.      * @param int $lob handle to a lob created by the createLob() function
  608.      * @param blob $data reference to a variable that will hold data to be
  609.      *       read from the large object input stream
  610.      * @param int $length integer value that indicates the largest ammount of
  611.      *       data to be read from the large object input stream.
  612.      * @return mixed length on success, a MDB error on failure
  613.      * @access private
  614.      */
  615.     function _readResultLOB($lob&$data$length)
  616.     {
  617.         $db =$GLOBALS['_MDB2_databases'][$this->db_index];
  618.         if (MDB2::isError($lobresult $this->_retrieveLOB($lob))) {
  619.             return $lobresult;
  620.         }
  621.         $data @ibase_blob_get($db->lobs[$lob]['handle']$length);
  622.         if (!is_string($data)) {
  623.             $db->raiseError(MDB2_ERRORNULLNULL,
  624.                 'Read Result LOB: ' @ibase_errmsg());
  625.         }
  626.         if (($length strlen($data)) == 0{
  627.             $db->lobs[$lob]['EndOfLOB'= 1;
  628.         }
  629.         return $length;
  630.     }
  631.  
  632.     // }}}
  633.     // {{{ _destroyResultLOB()
  634.  
  635.     /**
  636.      * Free any resources allocated during the lifetime of the large object
  637.      * handler object.
  638.      *
  639.      * @param int $lob handle to a lob created by the createLob() function
  640.      * @access private
  641.      */
  642.     function _destroyResultLOB($lob)
  643.     {
  644.         $db =$GLOBALS['_MDB2_databases'][$this->db_index];
  645.         if (isset($db->lobs[$lob])) {
  646.             if (isset($db->lobs[$lob]['value'])) {
  647.                @ibase_blob_close($db->lobs[$lob]['handle']);
  648.             }
  649.             $db->lobs[$lob'';
  650.         }
  651.     }
  652.  
  653.     // }}}
  654. }
  655. ?>

Documentation generated on Mon, 11 Mar 2019 10:15:47 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.