Example #1
0
function DB_lo_create($conn)
{
    if (strcmp(phpversion(), '4.2.0') < 0) {
        return pg_locreate($conn);
    } else {
        return pg_lo_create($conn);
    }
}
Example #2
0
 function GetLOBFieldValue($prepared_query, $parameter, $lob, &$value)
 {
     if (!$this->Connect()) {
         return 0;
     }
     if ($this->auto_commit && !@pg_Exec($this->connection, "BEGIN")) {
         return 0;
     }
     $success = 1;
     if ($lo = pg_locreate($this->connection)) {
         if ($handle = pg_loopen($this->connection, $lo, "w")) {
             while (!MetabaseEndOfLOB($lob)) {
                 if (MetabaseReadLOB($lob, $data, $this->lob_buffer_length) < 0) {
                     $this->SetError("Get LOB field value", MetabaseLOBError($lob));
                     $success = 0;
                     break;
                 }
                 if (!pg_lowrite($handle, $data)) {
                     $this->SetError("Get LOB field value", pg_ErrorMessage($this->connection));
                     $success = 0;
                     break;
                 }
             }
             pg_loclose($handle);
             if ($success) {
                 $value = strval($lo);
             }
         } else {
             $this->SetError("Get LOB field value", pg_ErrorMessage($this->connection));
             $success = 0;
         }
         if (!$success) {
             pg_lounlink($this->connection, $lo);
         }
     } else {
         $this->SetError("Get LOB field value", pg_ErrorMessage($this->connection));
         $success = 0;
     }
     if ($this->auto_commit) {
         @pg_Exec($this->connection, "END");
     }
     return $success;
 }
Example #3
0
 /**
  * Convert a text value into a DBMS specific format that is suitable to
  * compose query statements.
  *
  * @param resource  $prepared_query query handle from prepare()
  * @param           $parameter
  * @param           $lob
  * @return string text string that represents the given argument value in
  *      a DBMS specific format.
  * @access private
  */
 function _getLobValue($prepared_query, $parameter, $lob)
 {
     $connect = $this->connect();
     if (MDB::isError($connect)) {
         return $connect;
     }
     if ($this->auto_commit && !@pg_exec($this->connection, 'BEGIN')) {
         return $this->raiseError(MDB_ERROR, NULL, NULL, '_getLobValue: error starting transaction');
     }
     if ($lo = @pg_locreate($this->connection)) {
         if ($handle = @pg_loopen($this->connection, $lo, 'w')) {
             while (!$this->endOfLob($lob)) {
                 $result = $this->readLob($lob, $data, $this->options['lob_buffer_length']);
                 if (MDB::isError($result)) {
                     break;
                 }
                 if (!@pg_lowrite($handle, $data)) {
                     $result = $this->raiseError(MDB_ERROR, NULL, NULL, 'Get LOB field value: ' . @pg_errormessage($this->connection));
                     break;
                 }
             }
             @pg_loclose($handle);
             if (!MDB::isError($result)) {
                 $value = strval($lo);
             }
         } else {
             $result = $this->raiseError(MDB_ERROR, NULL, NULL, 'Get LOB field value: ' . @pg_errormessage($this->connection));
         }
         if (MDB::isError($result)) {
             $result = @pg_lounlink($this->connection, $lo);
         }
     } else {
         $result = $this->raiseError(MDB_ERROR, NULL, NULL, 'Get LOB field value: ' . pg_ErrorMessage($this->connection));
     }
     if ($this->auto_commit) {
         @pg_exec($this->connection, 'END');
     }
     if (MDB::isError($result)) {
         return $result;
     }
     return $value;
 }
Example #4
0
 function Create()
 {
     if (version_compare(phpversion(), "4.2.0", "ge") > 0) {
         $this->oid = pg_lo_create($this->dbconnect);
     } else {
         $this->oid = pg_locreate($this->dbconnect);
     }
 }
Example #5
0
 /**
  * Convert a text value into a DBMS specific format that is suitable to
  * compose query statements.
  *
  * @param resource  $prepared_query query handle from prepare()
  * @param           $parameter
  * @param           $lob
  * @return string text string that represents the given argument value in
  *      a DBMS specific format.
  * @access private
  */
 function _quoteLOB($lob)
 {
     $db =& $GLOBALS['_MDB2_databases'][$this->db_index];
     $connect = $db->connect();
     if (MDB2::isError($connect)) {
         return $connect;
     }
     $prepared_query = $GLOBALS['_MDB2_LOBs'][$lob]->prepared_query;
     $parameter = $GLOBALS['_MDB2_LOBs'][$lob]->parameter;
     if ($db->auto_commit && !@pg_exec($db->connection, 'BEGIN')) {
         return $db->raiseError(MDB2_ERROR, null, null, 'error starting transaction');
     }
     if ($lo = @pg_locreate($db->connection)) {
         if ($handle = @pg_loopen($db->connection, $lo, 'w')) {
             while (!$this->endOfLOB($lob)) {
                 $result = $this->readLOB($lob, $data, $db->options['lob_buffer_length']);
                 if (MDB2::isError($result)) {
                     break;
                 }
                 if (!pg_lowrite($handle, $data)) {
                     $result = $db->raiseError();
                     break;
                 }
             }
             @pg_loclose($handle);
             if (!MDB2::isError($result)) {
                 $value = strval($lo);
             }
         } else {
             $result = $db->raiseError();
         }
         if (MDB2::isError($result)) {
             $result = @pg_lounlink($db->connection, $lo);
         }
     } else {
         $result = $db->raiseError();
     }
     if ($db->auto_commit) {
         @pg_exec($db->connection, 'END');
     }
     if (MDB2::isError($result)) {
         return $result;
     }
     return $value;
 }