/** * 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]; if (MDB2::isError($connect = $db->connect())) { return $connect; } $prepared_query = $GLOBALS['_MDB2_LOBs'][$lob]->prepared_query; $parameter = $GLOBALS['_MDB2_LOBs'][$lob]->parameter; $value = ''; // DEAL WITH ME if (!($db->transaction_id = @ibase_trans(IBASE_COMMITTED, $db->connection))) { return $db->raiseError(MDB2_ERROR, null, null, 'Could not start a new transaction: ' . ibase_errmsg()); } if ($lo = @ibase_blob_create($db->auto_commit ? $db->connection : $db->transaction_id)) { while (!$this->endOfLOB($lob)) { $result = $this->readLOB($lob, $data, $db->options['lob_buffer_length']); if (MDB2::isError($result)) { break; } if (@ibase_blob_add($lo, $data) === false) { $result = $db->raiseError(MDB2_ERROR, null, null, 'Could not add data to a large object: ' . ibase_errmsg()); break; } } if (MDB2::isError($result)) { @ibase_blob_cancel($lo); } else { $value = @ibase_blob_close($lo); } } else { $result = $db->raiseError(); } if (!isset($db->query_parameters[$prepared_query])) { $db->query_parameters[$prepared_query] = array(0, ''); $db->query_parameter_values[$prepared_query] = array(); } $query_parameter = count($db->query_parameters[$prepared_query]); $db->query_parameters[$prepared_query][$query_parameter] = $value; $db->query_parameter_values[$prepared_query][$parameter] = $query_parameter; $value = '?'; if (!$db->auto_commit) { $db->commit(); } return $value; }
function GetLOBFieldValue($prepared_query, $parameter, $lob, &$value) { if (!$this->Connect()) { return 0; } $success = 1; if ($blob = ibase_blob_create($this->auto_commit ? $this->connection : $this->transaction_id)) { while (!MetabaseEndOfLOB($lob)) { if (MetabaseReadLOB($lob, $data, $this->lob_buffer_length) < 0) { $this->SetError("Get LOB field value", MetabaseLOBError($lob)); $success = 0; break; } if (!ibase_blob_add($blob, $data)) { $this->SetError("Get LOB field value", "Could not add data to a large object: " . ibase_errmsg()); $success = 0; break; } } if ($success) { if (GetType($value = ibase_blob_close($blob))) { if (!isset($this->query_parameters[$prepared_query])) { $this->query_parameters[$prepared_query] = array(0, ""); $this->query_parameter_values[$prepared_query] = array(); } $query_parameter = count($this->query_parameters[$prepared_query]); $this->query_parameter_values[$prepared_query][$parameter] = $query_parameter; $this->query_parameters[$prepared_query][$query_parameter] = $value; $value = "?"; } else { $success = 0; } } if (!$success) { ibase_blob_cancel($blob); } } else { $this->SetError("Get LOB field value", "Could not create a large object: " . ibase_errmsg()); $success = 0; } return $success; }
/** * 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) { if (MDB::isError($connect = $this->connect())) { return $connect; } $value = ''; // DEAL WITH ME if (!($this->transaction_id = @ibase_trans(IBASE_COMMITTED, $this->connection))) { return $this->raiseError(MDB_ERROR, NULL, NULL, '_getLobValue: Could not start a new transaction: ' . @ibase_errmsg()); } if ($lo = @ibase_blob_create($this->auto_commit ? $this->connection : $this->transaction_id)) { while (!$this->endOfLob($lob)) { if (MDB::isError($result = $this->readLob($lob, $data, $this->options['lob_buffer_length']))) { break; } if (@ibase_blob_add($lo, $data) === false) { $result = $this->raiseError(MDB_ERROR, NULL, NULL, '_getLobValue - Could not add data to a large object: ' . @ibase_errmsg()); break; } } if (MDB::isError($result)) { @ibase_blob_cancel($lo); } else { $value = @ibase_blob_close($lo); } } else { $result = $this->raiseError(MDB_ERROR, NULL, NULL, 'Get LOB field value' . @ibase_errmsg()); } if (!isset($this->query_parameters[$prepared_query])) { $this->query_parameters[$prepared_query] = array(0, ''); $this->query_parameter_values[$prepared_query] = array(); } $query_parameter = count($this->query_parameters[$prepared_query]); $this->query_parameter_values[$prepared_query][$parameter] = $query_parameter; $this->query_parameters[$prepared_query][$query_parameter] = $value; $value = '?'; if (!$this->auto_commit) { $this->commit(); } return $value; }