本文整理汇总了PHP中pg_escape_bytea函数的典型用法代码示例。如果您正苦于以下问题:PHP pg_escape_bytea函数的具体用法?PHP pg_escape_bytea怎么用?PHP pg_escape_bytea使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pg_escape_bytea函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: decrypt
/**
* see crypt::decrypt();
*/
public function decrypt($data)
{
$this->send_key_to_db();
$db = new db($this->db_link);
$result = $db->query("SELECT sm.decrypt('" . pg_escape_bytea($data) . "') AS decrypted;");
return $result['rows'][0]['decrypted'] ?? false;
}
示例2: GetBlobFieldValueAsSQL
protected function GetBlobFieldValueAsSQL($value) {
if (is_array($value)) {
return '\'' . pg_escape_bytea(file_get_contents($value[0])) . '\'';
} else {
return '\'' . pg_escape_bytea($value) . '\'';
}
}
示例3: binary_sql
function binary_sql($bin)
{
if (DB::connection() instanceof \Illuminate\Database\PostgresConnection) {
$bin = pg_escape_bytea($bin);
$bin = str_replace("''", "'", $bin);
}
return $bin;
}
示例4: getBlobSql
/**
*
* @param mixed $blob Blob object or string containing data.
* @return string
*/
protected function getBlobSql($blob)
{
// they took magic __toString() out of PHP5.0.0; this sucks
if (is_object($blob)) {
$blob = $blob->__toString();
}
return "'" . pg_escape_bytea($blob) . "'";
}
示例5: _quote
function _quote($s)
{
if (USE_BYTEA) {
return pg_escape_bytea($s);
} else {
// pg_escape_string() is broken
return base64_encode($s);
}
}
示例6: addSlashesBinary
/**
* @param String str
* @return String
*/
public function addSlashesBinary($str)
{
if ($this->postgreDbVersion < 9) {
return "'" . pg_escape_bytea($str) . "'";
}
if (!strlen($str)) {
return "''";
}
return "E'\\\\x" . bin2hex($str) . "'";
}
示例7: AddRegistro
public function AddRegistro($datos)
{
extract($datos);
$data = file_get_contents('imagenes/' . $imagen);
$image = pg_escape_bytea($data);
$sql = "INSERT INTO imagen(nombre, rutaim, imagen, tipoim, tamima, idimag) VALUES ('{$nombre}', '{$ruta}', '{$image}', '{$tipo}', '{$taman}',{$idimagen})";
pg_query($conn, $sql);
pg_close($conn);
return true;
}
示例8: getInsertValues
/**
* @since 1.8
*
* {@inheritDoc}
*/
public function getInsertValues(DataItem $dataItem)
{
$serialization = rawurldecode($dataItem->getSerialization());
$text = mb_strlen($serialization) <= self::MAX_LENGTH ? null : $serialization;
// bytea type handling
if ($text !== null && $GLOBALS['wgDBtype'] === 'postgres') {
$text = pg_escape_bytea($text);
}
return array('o_blob' => $text, 'o_serialized' => $serialization);
}
示例9: _quote
function _quote($s)
{
if (USE_BYTEA) {
return pg_escape_bytea($s);
}
if (function_exists('pg_escape_string')) {
return pg_escape_string($s);
} else {
return base64_encode($s);
}
}
示例10: db_addslashesbinary
function db_addslashesbinary($str)
{
global $postgreDbVersion;
if( $postgreDbVersion < 9 )
return "'".pg_escape_bytea($str)."'";
if(!strlen($str))
return "''";
return "E'\\\\x".bin2hex($str)."'";
}
示例11: GetFieldValueAsSQL
public function GetFieldValueAsSQL($fieldInfo, $value)
{
if ($fieldInfo->FieldType == ftBlob) {
if (is_array($value)) {
return '\'' . pg_escape_bytea(file_get_contents($value[0])) . '\'';
} else {
return '\'' . pg_escape_bytea($value) . '\'';
}
} else {
return parent::GetFieldValueAsSQL($fieldInfo, $value);
}
}
示例12: quoteBinary
public function quoteBinary($data)
{
$esc = pg_escape_bytea($this->getLink(), $data);
if (mb_strpos($esc, '\\x') === 0) {
// http://www.postgresql.org/docs/9.1/static/datatype-binary.html
// if pg_escape_bytea use postgres 9.1+ it's return value like '\x00aabb' (new bytea hex format),
// but must return '\\x00aabb'. So we use this fix:'
return "E'\\" . $esc . "'";
} else {
//if function escape value like '\\000\\123' - all ok
return "E'" . $esc . "'";
}
}
示例13: execute
public function execute()
{
try {
if (request::getInstance()->isMethod('POST')) {
$ruta = configClass::getUrlBase() . 'objeto';
$foto = $_FILES[datosUsuarioTableClass::getNameField(datosUsuarioTableClass::FOTO, true)]['tmp_name'];
$nombreArchivo = $_FILES[datosUsuarioTableClass::getNameField(datosUsuarioTableClass::FOTO, true)]['name'];
move_uploaded_file($foto, $ruta . "/" . $nombreArchivo);
$ruta = $ruta . "/" . $nombreArchivo;
$dataImg = file_get_contents($foto);
$img = pg_escape_bytea($dataImg);
// echo $dataImg;
// exit();
//usuario
$id = request::getInstance()->getPost(usuarioTableClass::getNameField(usuarioTableClass::ID, true));
$usuario = request::getInstance()->getPost(usuarioTableClass::getNameField(usuarioTableClass::USER, true));
$password = request::getInstance()->getPost(usuarioTableClass::getNameField(usuarioTableClass::PASSWORD, true));
$recuperar = request::getInstance()->getPost(usuarioTableClass::getNameField(usuarioTableClass::RESTAURAR_ID, true));
$respuesta_secreta = request::getInstance()->getPost(usuarioTableClass::getNameField(usuarioTableClass::RESPUESTA_SECRETA, true));
$idUser = array(usuarioTableClass::ID => $id);
$data = array(usuarioTableClass::USER => $usuario, usuarioTableClass::PASSWORD => md5($password), usuarioTableClass::RESTAURAR_ID => $recuperar, usuarioTableClass::RESPUESTA_SECRETA => $respuesta_secreta);
usuarioTableClass::update($idUser, $data);
$dataUser = array(usuarioTableClass::USER => $usuario, usuarioTableClass::PASSWORD => md5($password), usuarioTableClass::RESTAURAR_ID => $recuperar, usuarioTableClass::RESPUESTA_SECRETA => $respuesta_secreta);
//datos usuario
$nombre = request::getInstance()->getPost(datosUsuarioTableClass::getNameField(datosUsuarioTableClass::NOMBRE, true));
$apellidos = request::getInstance()->getPost(datosUsuarioTableClass::getNameField(datosUsuarioTableClass::APELLIDOS, true));
$tipoDocumento = request::getInstance()->getPost(datosUsuarioTableClass::getNameField(datosUsuarioTableClass::TIPO_DOC, true));
$numeroDocumento = request::getInstance()->getPost(datosUsuarioTableClass::getNameField(datosUsuarioTableClass::NUMERO_DOCUMENTO, true));
$direccion = request::getInstance()->getPost(datosUsuarioTableClass::getNameField(datosUsuarioTableClass::DIRECCION, true));
$idCiudad = request::getInstance()->getPost(datosUsuarioTableClass::getNameField(datosUsuarioTableClass::CIUDAD_ID, true));
$telefono = request::getInstance()->getPost(datosUsuarioTableClass::getNameField(datosUsuarioTableClass::TELEFONO, true));
$correo = request::getInstance()->getPost(datosUsuarioTableClass::getNameField(datosUsuarioTableClass::CORREO, true));
$datosUsuario = array(datosUsuarioTableClass::NOMBRE => $nombre, datosUsuarioTableClass::APELLIDOS => $apellidos, datosUsuarioTableClass::TIPO_DOC => $tipoDocumento, datosUsuarioTableClass::NUMERO_DOCUMENTO => $numeroDocumento, datosUsuarioTableClass::DIRECCION => $direccion, datosUsuarioTableClass::CIUDAD_ID => $idCiudad, datosUsuarioTableClass::TELEFONO => $telefono, datosUsuarioTableClass::CORREO => $correo);
$idData = array(datosUsuarioTableClass::USUARIO_ID => $id);
// usuarioTableClass::validatUpdate($usuario, $password);
datosUsuarioTableClass::update($idData, $datosUsuario);
usuarioTableClass::update($idUser, $dataUser);
session::getInstance()->setSuccess(i18n::__('succesUpdate', null, 'default'));
log::register(i18n::__('update'), usuarioTableClass::getNameTable());
routing::getInstance()->redirect('usuario', 'indexUsuario');
} else {
log::register(i18n::__('update'), usuarioTableClass::getNameTable(), i18n::__('errorUpdateBitacora'));
session::getInstance()->setError(i18n::__('errorUpdate', null, 'default'));
routing::getInstance()->redirect('usuario', 'indexUsuario');
}
} catch (PDOException $exc) {
session::getInstance()->setFlash('exc', $exc);
routing::getInstance()->forward('shfSecurity', 'exception');
}
}
示例14: esc
public function esc($data, $mode = self::STRING)
{
switch ($mode) {
case "literal":
$data = pg_escape_literal($this->connection, $data);
break;
case "bytea":
$data = pg_escape_bytea($this->connection, $data);
break;
default:
$data = pg_escape_string($this->connection, $data);
break;
}
return $data;
}
示例15: test_postgis
function test_postgis($name, $type, $geom, $connection, $format)
{
global $table;
// Let's insert into the database using GeomFromWKB
$insert_string = pg_escape_bytea($geom->out($format));
pg_query($connection, "INSERT INTO {$table} (name, type, geom) values ('{$name}', '{$type}', GeomFromWKB('{$insert_string}'))");
// SELECT using asBinary PostGIS
$result = pg_fetch_all(pg_query($connection, "SELECT asBinary(geom) as geom FROM {$table} WHERE name='{$name}'"));
foreach ($result as $item) {
$wkb = pg_unescape_bytea($item['geom']);
// Make sure to unescape the hex blob
$geom = geoPHP::load($wkb, $format);
// We now a full geoPHP Geometry object
}
// SELECT and INSERT directly, with no wrapping functions
$result = pg_fetch_all(pg_query($connection, "SELECT geom as geom FROM {$table} WHERE name='{$name}'"));
foreach ($result as $item) {
$wkb = pack('H*', $item['geom']);
// Unpacking the hex blob
$geom = geoPHP::load($wkb, $format);
// We now have a geoPHP Geometry
// Let's re-insert directly into postGIS
// We need to unpack the WKB
$unpacked = unpack('H*', $geom->out($format));
$insert_string = $unpacked[1];
pg_query($connection, "INSERT INTO {$table} (name, type, geom) values ('{$name}', '{$type}', '{$insert_string}')");
}
// SELECT and INSERT using as EWKT (ST_GeomFromEWKT and ST_AsEWKT)
$result = pg_fetch_all(pg_query($connection, "SELECT ST_AsEWKT(geom) as geom FROM {$table} WHERE name='{$name}'"));
foreach ($result as $item) {
$wkt = $item['geom'];
// Make sure to unescape the hex blob
$geom = geoPHP::load($wkt, 'ewkt');
// We now a full geoPHP Geometry object
// Let's re-insert directly into postGIS
$insert_string = $geom->out('ewkt');
pg_query($connection, "INSERT INTO {$table} (name, type, geom) values ('{$name}', '{$type}', ST_GeomFromEWKT('{$insert_string}'))");
}
}