/**
* Escapes the value given with pg_escape_bytea
*
* @param mixed $value
* @param resource $conn the postgresql connection. If none is given, it will use the last link opened,
* per behavior of pg_escape_bytea
* @return mixed
*
* @link http://php.net/manual/en/function.pg-escape-bytea.php
*/
public static function escPgSQLBytea($value, $conn = null)
{
if (Inspekt::isArrayOrArrayObject($value)) {
return Inspekt::walkArray($value, 'escPgSQL');
} else {
//might also check is_resource if pg_connection_status is too much
if (isset($conn) && pg_connection_status($conn) === PGSQL_CONNECTION_OK) {
return pg_escape_bytea($conn, $value);
} else {
return pg_escape_bytea($value);
}
}
}