本文整理汇总了PHP中pg_escape_bytea函数的典型用法代码示例。如果您正苦于以下问题:PHP pg_escape_bytea函数的具体用法?PHP pg_escape_bytea怎么用?PHP pg_escape_bytea使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pg_escape_bytea函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:volodymyr-volynets,项目名称:backend,代码行数:10,代码来源:base.php
示例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) . '\'';
}
}
开发者ID:jsrxar,项目名称:dto,代码行数:7,代码来源:pgsql_engine.php
示例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;
}
开发者ID:LulzNews,项目名称:infinity-next,代码行数:8,代码来源:binary.php
示例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) . "'";
}
开发者ID:nmicht,项目名称:tlalokes-in-acst,代码行数:13,代码来源:PgsqlDataSQLBuilder.php
示例5: _quote
function _quote($s)
{
if (USE_BYTEA) {
return pg_escape_bytea($s);
} else {
// pg_escape_string() is broken
return base64_encode($s);
}
}
开发者ID:neymanna,项目名称:fusionforge,代码行数:9,代码来源:PearDB_pgsql.php
示例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) . "'";
}
开发者ID:ryanblanchard,项目名称:Dashboard,代码行数:14,代码来源:PostgreFunctions.php
示例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;
}
开发者ID:edigiarch,项目名称:sisregcivil,代码行数:10,代码来源:Administracion.php
示例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);
}
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:15,代码来源:DIUriHandler.php
示例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);
}
}
开发者ID:hugcoday,项目名称:wiki,代码行数:11,代码来源:PearDB_pgsql.php
示例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)."'";
}
开发者ID:helbertfurbino,项目名称:sgmofinanceiro,代码行数:11,代码来源:dbfunctions.pg.php
示例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);
}
}
开发者ID:blakeHelm,项目名称:BallotPath,代码行数:12,代码来源:pgsql_engine.php
示例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 . "'";
}
}
开发者ID:justthefish,项目名称:hesper,代码行数:13,代码来源:PostgresDialect.php
示例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');
}
}
开发者ID:vixhymartinez,项目名称:proyecto_porcicola,代码行数:50,代码来源:updateUsuarioActionClass.php
示例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;
}
开发者ID:jankovacs,项目名称:php-legs,代码行数:15,代码来源:PostgreSQL.php
示例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}'))");
}
}
开发者ID:drupdateio,项目名称:gvj,代码行数:39,代码来源:postgis.php
示例16: Inserta
public function Inserta()
{
session_start();
$especies = new EspeciesModel();
$directorio = $_SERVER['DOCUMENT_ROOT'] . '/uploads/';
if (isset($_POST["nombre_especies"])) {
$_nombre_especies = strtoupper($_POST["nombre_especies"]);
$nombre = $_FILES['logo_especies']['name'];
$tipo = $_FILES['logo_especies']['type'];
$tamano = $_FILES['logo_especies']['size'];
// temporal al directorio definitivo
move_uploaded_file($_FILES['logo_especies']['tmp_name'], $directorio . $nombre);
$data = file_get_contents($directorio . $nombre);
$logo_especies = pg_escape_bytea($data);
$funcion = "ins_especies";
$parametros = " '{$_nombre_especies}' ,'{$logo_especies}' ";
$especies->setFuncion($funcion);
$especies->setParametros($parametros);
$resultado = $especies->Insert();
$this->redirect("Especies", "index");
}
}
开发者ID:mannyalbert81,项目名称:espejo,代码行数:22,代码来源:EspeciesController.php
示例17: geometryToDatabaseValue
public function geometryToDatabaseValue(\Geometry $value = null)
{
return $value === null ? null : pg_escape_bytea($value->out('ewkt'));
}
开发者ID:agnetsolutions,项目名称:dbal,代码行数:4,代码来源:PostGISAdapter.php
示例18: sql_format
/**
* Format value to it can be used in sql query
*
* Type of value is one of:
* "n" - number (int or float)
* "N" - number (int or float) - allow NULL values
* "s" - string
* "S" - string - allow NULL values
* "b" - bool
* "B" - bool - allow NULL values
* "i" - image (binary data)
* "I" - image (binary data) - allow NULL values
* "t" - datetime
* "T" - datetime - allow NULL values
*
* @param mixed $val
* @param string $type
* @return string
*/
function sql_format($val, $type)
{
switch ($type) {
case "S":
if (is_null($val)) {
return "NULL";
}
case "s":
return "'" . addslashes($val) . "'";
case "N":
if (is_null($val)) {
return "NULL";
}
case "n":
return (int) $val;
case "B":
if (is_null($val)) {
return "NULL";
}
case "b":
if ($this->db_host['parsed']['phptype'] == 'mysql') {
return $val ? "1" : "0";
} else {
return $val ? "true" : "false";
}
case "I":
if (is_null($val)) {
return "NULL";
}
case "i":
if ($this->db_host['parsed']['phptype'] == 'pgsql') {
return "'" . pg_escape_bytea($val) . "'::bytea";
} else {
return "'" . $this->db->escapeSimple($val) . "'";
}
case "T":
if (is_null($val)) {
return "NULL";
}
case "t":
return "'" . gmdate("Y-m-d H:i:s", $val) . "'";
default:
return "";
}
}
开发者ID:BackupTheBerlios,项目名称:serweb,代码行数:64,代码来源:data_layer.php
示例19: encodeBlob
function encodeBlob($b)
{
return new Blob(pg_escape_bytea($b));
}
开发者ID:ui-libraries,项目名称:TIRWeb,代码行数:4,代码来源:DatabasePostgres.php
示例20: _quote
protected function _quote($text, $binary)
{
if ($binary) {
return pg_escape_bytea($this->_connection, $text);
} else {
return pg_escape_string($this->_connection, $text);
}
}
开发者ID:hadrienl,项目名称:jelix,代码行数:8,代码来源:pgsql.dbconnection.php
注:本文中的pg_escape_bytea函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论