本文整理汇总了PHP中pg_unescape_bytea函数的典型用法代码示例。如果您正苦于以下问题:PHP pg_unescape_bytea函数的具体用法?PHP pg_unescape_bytea怎么用?PHP pg_unescape_bytea使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pg_unescape_bytea函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: molecule_image
function molecule_image($params)
{
header("Content-type: image/PNG");
include "../config/config.php";
$chembl_id = $params[0];
$image_not_found_file = "{$app2base}/static/images/app/inf.png";
// Double check CHEMBL ID format
if (preg_match("/^chembl\\d+\$/i", $chembl_id, $matches) == 0) {
header('Content-Length: ' . filesize($image_not_found_file));
readfile($image_not_found_file);
exit(0);
}
// Get image from database
$db = pg_connect("user={$db_user} dbname={$db_name} host={$db_host} port={$db_port}");
$sqlImage = "SELECT mp.image from mol_pictures mp, molecule_dictionary md where md.molregno=mp.molregno and md.chembl_id=upper('{$chembl_id}')";
$result_p = pg_query($db, $sqlImage);
$row = pg_fetch_array($result_p);
// Print image
if ($row) {
print pg_unescape_bytea($row[image]);
} else {
header('Content-Length: ' . filesize($image_not_found_file));
readfile($image_not_found_file);
exit(0);
}
}
示例2: get_image_by_imageid
function get_image_by_imageid($imageid)
{
/*global $DB;
$st = sqlite3_query($DB['DB'], 'select * from images where imageid='.$imageid);
info(implode(',',sqlite3_fetch_array($st)));
info(sqlite3_column_type($st,3));
info(SQLITE3_INTEGER.','.SQLITE3_FLOAT.','.SQLITE3_TEXT.','.SQLITE3_BLOB.','.SQLITE3_NULL);
return 0;*/
global $DB;
$result = DBselect('select * from images where imageid=' . $imageid);
$row = DBfetch($result);
if ($row) {
if ($DB['TYPE'] == "ORACLE") {
if (!isset($row['image'])) {
return 0;
}
$row['image'] = $row['image']->load();
} else {
if ($DB['TYPE'] == "POSTGRESQL") {
$row['image'] = pg_unescape_bytea($row['image']);
} else {
if ($DB['TYPE'] == "SQLITE3") {
$row['image'] = pack('H*', $row['image']);
}
}
}
return $row;
} else {
return 0;
}
}
示例3: execute
public function execute($bindValues = array(), $additionalParameters = array(), $query = null)
{
$query = $this->getQuery();
if (!empty($this->binaries)) {
for ($i = 0, $c = count($this->binaries); $i < $c; $i++) {
$query = str_replace("__sbl_binary" . ($i + 1), $this->binaries[$i]->getData(), $query);
}
}
$result = parent::execute($bindValues, $additionalParameters, $query);
if (!$this->isSelect() || empty($result)) {
return $result;
}
$binaryColumns = array();
foreach ($this->metadata->getColumns() as $column) {
if ($column->isBinary()) {
$binaryColumns[] = $column->name;
}
}
if (!empty($binaryColumns)) {
foreach ($result as &$row) {
foreach ($binaryColumns as $colName) {
if (isset($row[$colName])) {
$row[$colName] = pg_unescape_bytea($row[$colName]);
}
}
}
}
return $result;
}
示例4: stripSlashesBinary
/**
* @param String str
* @return String
*/
public function stripSlashesBinary($str)
{
if ($this->postgreDbVersion < 9) {
return pg_unescape_bytea($str);
}
return hex2bin(substr($str, 2));
}
示例5: fetch
/**
* fetches next row into this objects var's
*
* Note: it is ovverridden to deal with automatic unescaping of blob data on pgsql,
* also dealing with the MDB2_PORTABILITY_RTRIM option which needs to be disabled
* in order to retrieve correct binary data
*
* @access public
* @return boolean on success
*/
function fetch()
{
$oDbh =& $this->getDatabaseConnection();
if (empty($oDbh)) {
return false;
}
// When using PgSQL we need to disable MDB2_PORTABILITY_RTRIM portability option
if ($pgsql = $oDbh->dbsyntax == 'pgsql') {
$portability = $oDbh->getOption('portability');
if ($rtrim = $portability & MDB2_PORTABILITY_RTRIM) {
$oDbh->setOption('portability', $portability ^ MDB2_PORTABILITY_RTRIM);
}
}
// Fetch result
$result = parent::fetch();
// Reset portability options, in case they have been modified
if ($pgsql && $rtrim) {
$oDbh->setOption('portability', $portability);
}
// Unescape data on PgSQL
if ($pgsql && $result) {
$this->contents = pg_unescape_bytea($this->contents);
}
return $result;
}
示例6: getFilePath
public static function getFilePath($oid, $postfix = "picture.jpg")
{
$file = 'app/cache/file/' . $oid . "_{$postfix}";
$model = PgFileStore::getModel();
$data = $model->getWithField("object_id", $oid);
file_put_contents($file, pg_unescape_bytea($data[0]["data"]));
return $file;
}
示例7: db_stripslashesbinary
function db_stripslashesbinary($str)
{
global $postgreDbVersion;
if( $postgreDbVersion < 9 )
return pg_unescape_bytea($str);
return hex2bin( substr($str, 2) );
}
示例8: _unquote
function _unquote($s)
{
if (USE_BYTEA) {
return pg_unescape_bytea($s);
} else {
return base64_decode($s);
}
}
示例9: binary_unsql
function binary_unsql($bin)
{
if (is_resource($bin)) {
$bin = stream_get_contents($bin);
}
if (DB::connection() instanceof \Illuminate\Database\PostgresConnection) {
return pg_unescape_bytea($bin);
}
return $bin;
}
示例10: profile_picture
function profile_picture($netid)
{
init_db();
$query = "SELECT * FROM images WHERE (netid='" . pg_escape_string($netid) . "' AND profile=true) OR image_id='1' ORDER BY image_id DESC";
$results = pg_query($query);
$raw_img = pg_unescape_bytea(pg_fetch_result($results, 0, "image"));
pg_free_result($results);
header("Content-type: image/jpeg");
print $raw_img;
}
示例11: fetch_next
private function fetch_next()
{
$row = pg_fetch_assoc($this->result);
if ($this->blobs) {
foreach ($this->blobs as $blob) {
$row[$blob] = pg_unescape_bytea($row[$blob]);
}
}
return $row;
}
示例12: zbx_unescape_image
function zbx_unescape_image($image)
{
global $DB;
$result = $image ? $image : 0;
if ($DB['TYPE'] == ZBX_DB_POSTGRESQL) {
$result = pg_unescape_bytea($image);
} elseif ($DB['TYPE'] == ZBX_DB_SQLITE3) {
$result = pack('H*', $image);
}
return $result;
}
示例13: _unquote
function _unquote($s)
{
if (USE_BYTEA) {
return pg_unescape_bytea($s);
}
if (function_exists('pg_escape_string')) {
return $s;
} else {
return base64_decode($s);
}
}
示例14: unserialize
public function unserialize($data)
{
$data = stream_get_contents($data);
if (substr($data, 0, 4) != 'SERG') {
return $data;
}
if (!$this->pdo_enabled) {
$data = pg_unescape_bytea($data);
}
return parent::unserialize($data);
}
示例15: zbx_unescape_image
function zbx_unescape_image($image)
{
global $DB;
$result = $image ? $image : 0;
if ($DB['TYPE'] == "POSTGRESQL") {
$result = pg_unescape_bytea($image);
} else {
if ($DB['TYPE'] == "SQLITE3") {
$result = pack('H*', $image);
}
}
return $result;
}