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

Source for file pgsql.php

Documentation is available at pgsql.php

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

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