$value) { $str .= " " . $key . "=" . $value; } $db = pg_connect($str); return $db; } function git_load_raw_obj($db, $hash) { $hash_needed = pg_escape_string($hash); $result = pg_query( $db, "SELECT content FROM objects WHERE hash = '" . $hash_needed . "'" ) or die_not_exists('Failed to query database.'); $row = pg_fetch_array($result, null, PGSQL_ASSOC); if ($row) { return pg_unescape_bytea($row['content']); } else { return null; } } function git_load_obj($db, $hash) { $hash_needed = pg_escape_string($hash); $result = pg_query( $db, "SELECT content FROM contents WHERE hash = '" . $hash_needed . "'" ) or die_not_exists('Failed to query database.'); $row = pg_fetch_array($result, null, PGSQL_ASSOC); if ($row) { return pg_unescape_bytea($row['content']); } else { return null; } } function git_load_refs($db) { $result = pg_query( $db, "SELECT name, git_resolve_ref(target) as target FROM refs" ) or die_server_error('Failed to query database for refs.'); return $result; }