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

Source for file pgsql.php

Documentation is available at pgsql.php

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

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