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); } } }