本文整理汇总了PHP中pg_fetch_assoc函数的典型用法代码示例。如果您正苦于以下问题:PHP pg_fetch_assoc函数的具体用法?PHP pg_fetch_assoc怎么用?PHP pg_fetch_assoc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pg_fetch_assoc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getNextRow
/**
* Internal method to fetch the next row from the result set
*
* @return array|null
*/
protected function getNextRow()
{
# If the result resource is invalid then don't bother trying to fetch
if (!$this->result) {
return;
}
switch ($this->mode) {
case "mysql":
$row = $this->result->fetch_assoc();
break;
case "postgres":
case "redshift":
$row = pg_fetch_assoc($this->result);
break;
case "odbc":
$row = odbc_fetch_array($this->result, $this->position + 1);
break;
case "sqlite":
$row = $this->result->fetchArray(SQLITE3_ASSOC);
break;
case "mssql":
$row = mssql_fetch_assoc($this->result);
break;
}
# If the fetch fails then there are no rows left to retrieve
if (!$row) {
return;
}
$this->position++;
return $row;
}
示例2: queryArray
function queryArray($query)
{
$this->connection = pg_connect("{$this->connstring}") or die("Connection failed: " . pg_last_error());
$result = pg_query($query) or die("Query failed: " . pg_last_error());
$fetch = pg_fetch_assoc($result);
return $fetch;
}
示例3: select
public function select($data)
{
$sql = $this->user_model->select($data);
$query = $this->conexion->query($sql, $this->conexion);
$row = pg_fetch_assoc($query);
return json_encode($row);
}
示例4: current
/**
* Current
*
* @return array|bool|mixed
*/
public function current()
{
if ($this->count === 0) {
return false;
}
return pg_fetch_assoc($this->resource, $this->position);
}
示例5: obtenerArregloAsociativo
public function obtenerArregloAsociativo($result)
{
if (!is_resource($result)) {
return false;
}
return pg_fetch_assoc($result);
}
示例6: getline
public function getline()
{
if ($this->resource === false) {
return;
}
return pg_fetch_assoc($this->resource);
}
示例7: printTable
function printTable($result)
{
//get the first row in the table:
if (!($row = pg_fetch_assoc($result))) {
return false;
}
//set up the table:
print "<table><tr>";
//print the column names as table headers:
foreach ($row as $key => $value) {
print "<th>{$key}</th>";
}
print "</tr>";
//loop through the table, printing
//the field values in table cells:
do {
print "<tr>";
foreach ($row as $key => $value) {
print "<td>{$value}</td>";
}
print "</tr>";
} while ($row = pg_fetch_assoc($result));
//close out the table:
print "</tr></table>";
return true;
}
示例8: get_servicecategoryname
function get_servicecategoryname($service_category_id)
{
$result = pg_query_params("select servicecategoryname from techmatcher.servicecategories where servicecategory_id=\$1", array($service_category_id));
//$service_iddd=array();
$category_name = pg_fetch_assoc($result);
return $category_name;
}
示例9: wikipedia_streetnames_info
function wikipedia_streetnames_info($info_ret, $object) {
global $data_lang;
$text="";
if(!$object->tags->get("highway"))
return;
$res=sql_query("select * from osm_polygon where osm_way && geomfromtext('{$object->data['way']}', 900913) and CollectionIntersects(osm_way, geomfromtext('{$object->data['way']}', 900913)) and osm_tags @> 'boundary=>administrative' order by parse_number(osm_tags->'admin_level') desc");
while($elem=pg_fetch_assoc($res)) {
$boundary=load_object($elem['osm_id']);
$data=cache_search($boundary->id, "wikipedia:street_names:$data_lang");
if($data) {
$data=unserialize($data);
}
else {
$data=wikipedia_get_lang_page($boundary, "wikipedia:street_names");
$article=wikipedia_get_article($boundary, $data['page'], $data['lang']);
$data['article']=$article;
cache_insert($boundary->id, "wikipedia:street_names:$data_lang",
serialize($data), "1 hour");
}
if($data['article']) {
$text.=wikipedia_streetnames_parse($data['article'], $object);
if($text) {
$text.="<br>".lang("source").": <a class='external' href='".wikipedia_url($boundary, $data['page'], $data['lang'])."'>Wikipedia</a>\n";
$info_ret[]=array("head"=>"wikipedia_streetnames", "content"=>$text, "doc"=>"plugin:wikipedia_streetnames/feature");
return;
}
}
}
}
示例10: initTables
/**
* @throws SQLException
* @return void
*/
protected function initTables()
{
include_once 'creole/drivers/pgsql/metadata/PgSQLTableInfo.php';
// Get Database Version
$result = pg_exec($this->dblink, "SELECT version() as ver");
if (!$result) {
throw new SQLException("Failed to select database version");
}
// if (!$result)
$row = pg_fetch_assoc($result, 0);
$arrVersion = sscanf($row['ver'], '%*s %d.%d');
$version = sprintf("%d.%d", $arrVersion[0], $arrVersion[1]);
// Clean up
$arrVersion = null;
$row = null;
pg_free_result($result);
$result = null;
$result = pg_exec($this->dblink, "SELECT oid, relname FROM pg_class\n\t\t\t\t\t\t\t\t\t\tWHERE relkind = 'r' AND relnamespace = (SELECT oid\n\t\t\t\t\t\t\t\t\t\tFROM pg_namespace\n\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t nspname NOT IN ('information_schema','pg_catalog')\n\t\t\t\t\t\t\t\t\t\t AND nspname NOT LIKE 'pg_temp%'\n\t\t\t\t\t\t\t\t\t\t AND nspname NOT LIKE 'pg_toast%'\n\t\t\t\t\t\t\t\t\t\tLIMIT 1)\n\t\t\t\t\t\t\t\t\t\tORDER BY relname");
if (!$result) {
throw new SQLException("Could not list tables", pg_last_error($this->dblink));
}
while ($row = pg_fetch_assoc($result)) {
$this->tables[strtoupper($row['relname'])] = new PgSQLTableInfo($this, $row['relname'], $version, $row['oid']);
}
}
示例11: Migrate_20_25
/**
* \brief
* delete from copyright where pfile_fk not in (select pfile_pk from pfile)
* add foreign constraint on copyright pfile_fk if not exist
*
* \return 0 on success, 1 on failure
**/
function Migrate_20_25($Verbose)
{
global $PG_CONN;
$sql = "select count(*) from pg_class where relname='copyright';";
$result = pg_query($PG_CONN, $sql);
DBCheckResult($result, $sql, __FILE__, __LINE__);
$row = pg_fetch_assoc($result);
pg_free_result($result);
if (1 > $row['count']) {
return 0;
// fresh install, even no copyright table
}
$sql = "delete from copyright where pfile_fk not in (select pfile_pk from pfile);";
$result = pg_query($PG_CONN, $sql);
DBCheckResult($result, $sql, __FILE__, __LINE__);
pg_free_result($result);
/** add foreign key CONSTRAINT on pfile_fk of copyrigyt table when not exist */
$sql = "SELECT conname from pg_constraint where conname= 'copyright_pfile_fk_fkey';";
$conresult = pg_query($PG_CONN, $sql);
DBCheckResult($conresult, $sql, __FILE__, __LINE__);
if (pg_num_rows($conresult) == 0) {
$sql = "ALTER TABLE copyright ADD CONSTRAINT copyright_pfile_fk_fkey FOREIGN KEY (pfile_fk) REFERENCES pfile (pfile_pk) ON DELETE CASCADE; ";
$result = pg_query($PG_CONN, $sql);
DBCheckResult($result, $sql, __FILE__, __LINE__);
pg_free_result($result);
print "add contr\n";
}
pg_free_result($conresult);
return 0;
}
示例12: hashDecode
function hashDecode($hashedUrl)
{
$urlEncode = new UrlEncode();
$result = array();
//No hash was given as input
if (!$hashedUrl) {
$result["error"] = "No input given";
} else {
$hashedUrl = $urlEncode->parseHash($hashedUrl);
if ($hashedUrl != -1) {
$id = $urlEncode->decodeToOriginalUrl($hashedUrl);
//Database stuff
global $dbConnStr;
//This comes from dbConfig.php
$dbConnection = pg_connect($dbConnStr);
$query = sprintf("SELECT url FROM urls WHERE id = %d", $id);
//sprintf to reduce SQL injection attack
$dbResult = pg_query($query);
$row = pg_fetch_assoc($dbResult);
if ($row) {
$result["originalUrl"] = $row["url"];
} else {
//The URL does not exist in our database
$result["error"] = "Url does not exist: {$hashedUrl}";
}
} else {
$result["error"] = "Hashed url host incorrect";
}
}
return json_encode($result);
}
示例13: listaDatos
public function listaDatos($resultado)
{
if (!is_resource($resultado)) {
return false;
}
return pg_fetch_assoc($resultado);
}
示例14: prepare_report
function prepare_report($shemaid)
{
$fname = tempnam("/tmp", "twrep");
//$report_fname=$client_dir."/".$fname.".csv";
$fw = fopen($fname, "w");
fputs($fw, "ts,location,userid,rtc,placecntry,placename\n");
$row = pg_fetch_row(pg_query("select t_id from scheme where id={$shemaid}"));
$tag_id = (int) $row[0];
$res = pg_query("select ts, location, userid, rtc, placecntry, placename from twits where t_id={$tag_id}");
while ($row = @pg_fetch_assoc($res)) {
// export row
$line = array();
$line[] = convert_to_cps_date($row["ts"]);
$line[] = $row["location"];
$line[] = $row["userid"];
$line[] = $row["rtc"];
$line[] = $row["placecntry"];
$line[] = $row["placename"];
fputcsv($fw, $line);
}
fclose($fw);
$zip = new ZipArchive();
$filename = "/tmp/twr" . $shemaid . ".zip";
if ($zip->open($filename, ZIPARCHIVE::CREATE) !== TRUE) {
die("cant open <{$filename}>\n");
}
$zip->addFile($fname, "data.csv");
$zip->close();
@unlink($fname);
return $filename;
}
示例15: makeCTFParams
function makeCTFParams()
{
$cnx = __dbConnect();
if (!$cnx) {
print "<b>DATABASE CONNECTION ERROR</b>";
exit(1);
}
$query = pg_query("SELECT * FROM main.ctf_map_def ORDER BY name");
if (!$query) {
print "<b>DATABASE ERROR</b>";
exit(1);
}
$ctfMaps = array();
while ($r = pg_fetch_assoc($query)) {
$ctfMaps[$r['id']] = $r;
$query2 = pg_query("SELECT COUNT(*) FROM main.ctf_map_layout WHERE map={$r['id']} AND spawn_here");
if (!$query2) {
print "<b>DATABASE ERROR</b>";
exit(1);
}
list($ctfMaps[$r['id']]['players']) = pg_fetch_array($query2);
pg_free_result($query2);
}
pg_free_result($query);
pg_close($cnx);
$map = $ctfMaps[$_SESSION['lw_new_game']['ctfmap']];
$cParams = $_SESSION['lw_new_game']['ctfparams'];
$params = array('usemap' => $map['id'], 'maxplayers' => $map['players'], 'norealloc' => 1, 'partialtechs' => 0, 'lockalliances' => $map['alliances'], 'alliancecap' => 0, 'victory' => 2, 'novacation' => 1);
foreach ($cParams as $p => $v) {
$params[$p] = $v;
}
return $params;
}