本文整理汇总了PHP中pg_freeresult函数的典型用法代码示例。如果您正苦于以下问题:PHP pg_freeresult函数的具体用法?PHP pg_freeresult怎么用?PHP pg_freeresult使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pg_freeresult函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: next_record
function next_record()
{
$this->Record = @pg_fetch_array($this->Query_ID, $this->Row);
$this->Row += 1;
$this->Error = pg_errormessage();
$stat = is_array($this->Record);
if (!$stat) {
pg_freeresult($this->Query_ID);
$this->Query_ID = 0;
}
return $this->Record;
}
示例2: pg_insert_id
/**
* That one was messing the parser...
*/
function pg_insert_id($tablename, $fieldname)
{
$result = pg_exec($this->_connectionID, "SELECT last_value FROM {$tablename}_seq");
if ($result) {
$arr = @pg_fetch_row($result, 0);
pg_freeresult($result);
if (isset($arr[0])) {
return $arr[0];
}
}
return false;
}
示例3: next_record
function next_record()
{
$this->Record = @pg_fetch_array($this->Query_ID, $this->Row++);
$this->Error = pg_ErrorMessage($this->Link_ID);
$this->Errno = $this->Error == "" ? 0 : 1;
$stat = is_array($this->Record);
if (!$stat && $this->Auto_Free) {
pg_freeresult($this->Query_ID);
$this->Query_ID = 0;
}
return $stat;
}
示例4: query
/**
* Performs an SQL query.
*
* @param string $query
* @param mixed $limit
* @param boolean $warnOnFailure
* @access public
*/
function query($query, $limit = false, $warnOnFailure = true)
{
if ($limit != false) {
$query .= ' LIMIT ' . $limit;
}
if ($this->config['debug_level'] > 1) {
$this->debugQuery($query);
}
@pg_freeresult($this->result);
$this->result = @pg_exec($this->connection, $query);
if (!$this->result && $warnOnFailure) {
phpOpenTracker::handleError(@pg_errormessage($this->connection), E_USER_ERROR);
}
}
示例5: pg_freeresult
$title = $r[1];
$axislabel = $r[2];
$is_clickable = $r[3];
pg_freeresult($data);
// get graph data
$data = @pg_exec($db, $query) or die("PGERR 2: " . pg_ErrorMessage());
$v = array();
$l = array();
$u = array();
for ($i = 0; $i < pg_numrows($data); $i++) {
$r = pg_fetch_row($data, $i);
array_push($v, $r[1]);
array_push($l, $r[0] . " ");
array_push($u, $r[2]);
}
pg_freeresult($data);
// draw
$map = FreshPortsChart($title, $axislabel, $v, $l, $u, $filename);
if ($is_clickable == 't') {
// save map
$fp = fopen($cache_dir . $fid . ".map", "w");
fputs($fp, $map);
fclose($fp);
}
pg_close();
}
header("Content-type: image/png");
readfile($filename);
// CREATE TABLE "graph" ("id" integer NOT NULL, "query" text NOT NULL,
// "title" text NOT NULL);
// insert into graph (id, query, title) values (0,'select category,
示例6: next_record
/**
* Goto the next record in the result set.
*
* @return bool result of going to the next record
*/
public function next_record()
{
/* goto next record */
$this->m_record = @pg_fetch_array($this->m_query_id, $this->m_row, PGSQL_ASSOC);
++$this->m_row;
/* are we there? */
$result = is_array($this->m_record);
if (!$result && $this->m_auto_free) {
@pg_freeresult($this->m_query_id);
$this->m_query_id = 0;
}
/* return result */
return $result;
}
示例7: _close
function _close()
{
return @pg_freeresult($this->_queryID);
}
示例8: free_result
/**
*/
function free_result($query_id = false)
{
return $query_id ? pg_freeresult($query_id) : false;
}
示例9: _query
function _query($sql, $inputarr = false)
{
if (!$this->_bindInputArray) {
// We don't have native support for parameterized queries, so let's emulate it at the parent
return ADODB_postgres64::_query($sql, $inputarr);
}
$this->_pnum = 0;
$this->_errorMsg = false;
// -- added Cristiano da Cunha Duarte
if ($inputarr) {
$sqlarr = explode('?', trim($sql));
$sql = '';
$i = 1;
$last = sizeof($sqlarr) - 1;
$localedata = localeconv();
foreach ($sqlarr as $v) {
if ($last < $i) {
$sql .= $v;
} else {
$sql .= $v . ' $' . $i;
}
$i++;
// pg_query_params may incorrectly format
// doubles using localized number formats, i.e.
// , instead of . for floats, violating the
// SQL standard. Format it locally.
$k = $i - 2;
// Use proper index for $inputarr to avoid going over the end
if ($k < $last) {
if (gettype($inputarr[$k]) == 'double') {
$inputarr[$k] = str_replace($localedata['decimal_point'], '.', $inputarr[$k]);
}
}
}
$rez = pg_query_params($this->_connectionID, $sql, $inputarr);
} else {
$rez = pg_query($this->_connectionID, $sql);
}
// check if no data returned, then no need to create real recordset
if ($rez && pg_numfields($rez) <= 0) {
if (is_resource($this->_resultid) && get_resource_type($this->_resultid) === 'pgsql result') {
pg_freeresult($this->_resultid);
}
$this->_resultid = $rez;
return true;
}
return $rez;
}
示例10: sql_freeresult
function sql_freeresult($query_id = 0)
{
if (!$query_id) {
$query_id = $this->query_result;
}
return $query_id ? @pg_freeresult($query_id) : false;
}
示例11: pg_free_result
/**
* pg_free_result
* Backwards compatible function
*/
function pg_free_result($result)
{
return pg_freeresult($result);
}
示例12: get_last_insert_id
function get_last_insert_id($table, $field)
{
if (!isset($table) || $table == '' || !isset($field) || $field == '') {
return -1;
}
$oid = pg_getlastoid($this->Query_ID);
if ($oid == -1) {
return -1;
}
$result = @pg_Exec($this->Link_ID, "select {$field} from {$table} where oid={$oid}");
if (!$result) {
return -1;
}
$Record = @pg_fetch_array($result, 0);
@pg_freeresult($result);
if (!is_array($Record)) {
return -1;
}
return $Record[0];
}
示例13: getInsertId
/**
* PostgreSQL::getInsertId()
*
* Get the id of the last inserted record
*
* @param string $table: de tabel waarvan de laatste id van terug gegeven moet worden
* @return int
* @access public
* @author Teye Heimans
*/
function getInsertId($table)
{
$k = $this->getPrKeys($table);
// select the last insert id for that table
$sql = $this->query("\r\n SELECT last_value\r\n FROM " . $this->quote($table . "_" . $k[0] . "_seq"));
// query failed?
if (!$sql) {
trigger_error("Could not retrieve the last inserted id for the table '" . $table . "'.\n" . "Query: " . $this->getLastQuery() . "\n" . "Error: " . $this->getError(), E_USER_WARNING);
return false;
}
// get the last inserted id
if ($this->recordCount($sql) == 1) {
$row = @pg_fetch_row($sql, 0);
pg_freeresult($sql);
return $row[0];
} else {
pg_freeresult($sql);
trigger_error("Could not retrieve the last inserted id for the table '" . $table . "'.\n" . "Query: " . $this->getLastQuery() . "\n" . "Error: " . $this->getError(), E_USER_WARNING);
return false;
}
}
示例14: pg_freeresult
} else {
pg_freeresult($registered);
$registered = pg_execute($conn, "register_stats", array($uid));
if (!$registered) {
pg_execute($conn, "delete_profile", array($uid)) or die("Can't execute delete_profile: " . pg_last_error());
pg_execute($conn, "delete_user", array($uid)) or die("Can't execute delete_user: " . pg_last_error());
}
}
}
if ($registered) {
pg_freeresult($registered);
dealloc_qrys($conn);
echo "<script type='text/javascript'>\n\t\t\tjSuccess('You have been registered! Please log in!',\n\t\t\t\t{\n\t\t\t\t\tonClosed:function()\n\t\t\t\t\t{\n\t\t\t\t\t\twindow.location.href='" . $root . "/index.php'\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\t\t\t</script>";
exit;
} else {
pg_freeresult($registered);
dealloc_qrys($conn);
echo "<script type='text/javascript'>\n\t\t\tjError('Oops, something went wrong...',\n\t\t\t\t{\n\t\t\t\t\tonClosed:function()\n\t\t\t\t\t{\n\t\t\t\t\t\twindow.location.href='" . $root . "/index.php'\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\t\t\t</script>";
exit;
}
}
}
} else {
header("Location: " . $root . "/index.php");
}
exit;
?>
</div><!-- container -->
</body>
</html>
示例15: sql_report
function sql_report($mode, $query = '')
{
if (empty($_GET['explain'])) {
return;
}
global $cache, $starttime, $phpbb_root_path;
static $curtime, $query_hold, $html_hold;
static $sql_report = '';
static $cache_num_queries = 0;
if (!$query && !empty($query_hold)) {
$query = $query_hold;
}
switch ($mode) {
case 'display':
if (!empty($cache)) {
$cache->unload();
}
$this->sql_close();
$mtime = explode(' ', microtime());
$totaltime = $mtime[0] + $mtime[1] - $starttime;
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8869-1"><meta http-equiv="Content-Style-Type" content="text/css"><link rel="stylesheet" href="' . $phpbb_root_path . 'adm/subSilver.css" type="text/css"><style type="text/css">' . "\n";
echo 'th { background-image: url(\'' . $phpbb_root_path . 'adm/images/cellpic3.gif\') }' . "\n";
echo 'td.cat { background-image: url(\'' . $phpbb_root_path . 'adm/images/cellpic1.gif\') }' . "\n";
echo '</style><title>' . $msg_title . '</title></head><body>';
echo '<table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td><a href="' . htmlspecialchars(preg_replace('/&explain=([^&]*)/', '', $_SERVER['REQUEST_URI'])) . '"><img src="' . $phpbb_root_path . 'adm/images/header_left.jpg" width="200" height="60" alt="phpBB Logo" title="phpBB Logo" border="0"/></a></td><td width="100%" background="' . $phpbb_root_path . 'adm/images/header_bg.jpg" height="60" align="right" nowrap="nowrap"><span class="maintitle">SQL Report</span> </td></tr></table><br clear="all"/><table width="95%" cellspacing="1" cellpadding="4" border="0" align="center"><tr><td height="40" align="center" valign="middle"><b>Page generated in ' . round($totaltime, 4) . " seconds with {$this->num_queries} queries" . ($cache_num_queries ? " + {$cache_num_queries} " . ($cache_num_queries == 1 ? 'query' : 'queries') . ' returning data from cache' : '') . '</b></td></tr><tr><td align="center" nowrap="nowrap">Time spent on MySQL queries: <b>' . round($this->sql_time, 5) . 's</b> | Time spent on PHP: <b>' . round($totaltime - $this->sql_time, 5) . 's</b></td></tr></table><table width="95%" cellspacing="1" cellpadding="4" border="0" align="center"><tr><td>';
echo $sql_report;
echo '</td></tr></table><br /></body></html>';
exit;
break;
case 'start':
$query_hold = $query;
$html_hold = '';
$curtime = explode(' ', microtime());
$curtime = $curtime[0] + $curtime[1];
break;
case 'fromcache':
$endtime = explode(' ', microtime());
$endtime = $endtime[0] + $endtime[1];
$result = @pg_exec($this->db_connect_id, $query);
while ($void = @pg_fetch_array($result, NULL, PGSQL_ASSOC)) {
// Take the time spent on parsing rows into account
}
$splittime = explode(' ', microtime());
$splittime = $splittime[0] + $splittime[1];
$time_cache = $endtime - $curtime;
$time_db = $splittime - $endtime;
$color = $time_db > $time_cache ? 'green' : 'red';
$sql_report .= '<hr width="100%"/><br /><table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0"><tr><th>Query results obtained from the cache</th></tr><tr><td class="row1"><textarea style="font-family:\'Courier New\',monospace;width:100%" rows="5">' . preg_replace('/\\t(AND|OR)(\\W)/', "\$1\$2", htmlspecialchars(preg_replace('/[\\s]*[\\n\\r\\t]+[\\n\\r\\s\\t]*/', "\n", $query))) . '</textarea></td></tr></table><p align="center">';
$sql_report .= 'Before: ' . sprintf('%.5f', $curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed [cache]: <b style="color: ' . $color . '">' . sprintf('%.5f', $time_cache) . 's</b> | Elapsed [db]: <b>' . sprintf('%.5f', $time_db) . 's</b></p>';
// Pad the start time to not interfere with page timing
$starttime += $time_db;
@pg_freeresult($result);
$cache_num_queries++;
break;
case 'stop':
$endtime = explode(' ', microtime());
$endtime = $endtime[0] + $endtime[1];
$sql_report .= '<hr width="100%"/><br /><table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0"><tr><th>Query #' . $this->num_queries . '</th></tr><tr><td class="row1"><textarea style="font-family:\'Courier New\',monospace;width:100%" rows="5">' . preg_replace('/\\t(AND|OR)(\\W)/', "\$1\$2", htmlspecialchars(preg_replace('/[\\s]*[\\n\\r\\t]+[\\n\\r\\s\\t]*/', "\n", $query))) . '</textarea></td></tr></table> ' . $html_hold . '<p align="center">';
if ($this->query_result) {
if (preg_match('/^(UPDATE|DELETE|REPLACE)/', $query)) {
$sql_report .= "Affected rows: <b>" . $this->sql_affectedrows($this->query_result) . '</b> | ';
}
$sql_report .= 'Before: ' . sprintf('%.5f', $curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed: <b>' . sprintf('%.5f', $endtime - $curtime) . 's</b>';
} else {
$error = $this->sql_error();
$sql_report .= '<b style="color: red">FAILED</b> - ' . SQL_LAYER . ' Error ' . $error['code'] . ': ' . htmlspecialchars($error['message']);
}
$sql_report .= '</p>';
$this->sql_time += $endtime - $curtime;
break;
}
}