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; }
function DB_lo_write($fp, $data) { if (strcmp(phpversion(), '4.2.0') < 0) { return pg_lowrite($fp, $data); } else { return pg_lo_write($fp, $data); } }
/** * 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; }
function Write($data) { if (!$this->oid || $this->error) { echo "{$this->error}<br>\n"; } else { if (version_compare(phpversion(), "4.2.0", "ge") > 0) { $this->error = pg_lo_write($this->result, $data); } else { $this->error = pg_lowrite($this->result, $data); } } }
/** * 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; }