本文整理汇总了PHP中pg_send_query函数的典型用法代码示例。如果您正苦于以下问题:PHP pg_send_query函数的具体用法?PHP pg_send_query怎么用?PHP pg_send_query使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pg_send_query函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: safe_dml_query
function safe_dml_query($query, $verbose = True)
{
global $conn;
if ($verbose) {
echo "------------------------\n";
echo "Executing PG query: {$query}\n";
}
$time_start = microtime(true);
pg_send_query($conn, $query) or die("Failed to execute query {$query}");
while (pg_connection_busy($conn)) {
if (microtime(true) - $time_start > 30) {
if (rand(0, 10) == 0) {
echo "Busy for " . round((microtime(true) - $time_start) * 1000) . " ms -";
}
sleep(5);
}
usleep(2000);
}
$res = pg_get_result($conn);
if (pg_result_error($res) != null) {
die("Error during query: " . pg_result_error($res) . "\n");
}
$time_end = microtime(true);
$rows = pg_affected_rows($res);
if ($verbose) {
echo "Done executing {$query}: {$rows} touched\n";
$t = round(($time_end - $time_start) * 1000);
echo "Query time: {$t} ms\n";
echo "------------------------\n";
}
}
开发者ID:johnpyeatt,项目名称:nominatiny,代码行数:31,代码来源:dbutils.inc.php
示例2: testUniqueCheck
public function testUniqueCheck($username, $email)
{
//Get info from the array
$final_username = $username;
$final_email = $email;
//Connect to the db
$db = $this->connectProd();
//Check for username and email address
$query_user_check = "SELECT username FROM tb_users WHERE username = '" . $final_username . "'";
$query_email_check = "SELECT email FROM tb_users WHERE email = '" . $final_email . "'";
pg_send_query($db, $query_user_check) or die('Query failed: ' . pg_last_error());
$username_check_result = pg_get_result($db);
$username_check_result_rows = pg_num_rows($username_check_result);
pg_close($db);
if ($username_check_result_rows == 0) {
//Set flag if no user found
$user_check = 'pass';
} else {
$user_check = 'fail';
}
if ($email_check_result_rows == 0) {
//Set flag if no email is found
$email_check = 'pass';
} else {
$email_check = 'fail';
}
if ($email_check == 'pass' && $user_check == 'pass') {
$check_result = 'pass';
return $check_result;
} else {
$check_result = 'fail';
return $check_result;
}
}
开发者ID:JackoThe1st,项目名称:OpenRPSDev,代码行数:34,代码来源:Db.php
示例3: query
function query($sql, $unbuffered = false)
{
if (strrpos($sql, 'LIMIT') !== false) {
$sql = preg_replace('%LIMIT ([0-9]+),([ 0-9]+)%', 'LIMIT \\2 OFFSET \\1', $sql);
}
if (defined('PUN_SHOW_QUERIES')) {
$q_start = get_microtime();
}
@pg_send_query($this->link_id, $sql);
$this->query_result = @pg_get_result($this->link_id);
if (pg_result_status($this->query_result) != PGSQL_FATAL_ERROR) {
if (defined('PUN_SHOW_QUERIES')) {
$this->saved_queries[] = array($sql, sprintf('%.5f', get_microtime() - $q_start));
}
++$this->num_queries;
$this->last_query_text[intval($this->query_result)] = $sql;
return $this->query_result;
} else {
if (defined('PUN_SHOW_QUERIES')) {
$this->saved_queries[] = array($sql, 0);
}
$this->error_no = false;
$this->error_msg = @pg_result_error($this->query_result);
if ($this->in_transaction) {
@pg_query($this->link_id, 'ROLLBACK');
}
--$this->in_transaction;
return false;
}
}
开发者ID:wenyinos,项目名称:fluxbb,代码行数:30,代码来源:pgsql.php
示例4: query
function query($sql, $unbuffered = false)
{
if (strlen($sql) > FORUM_DATABASE_QUERY_MAXIMUM_LENGTH) {
exit('Insane query. Aborting.');
}
if (strrpos($sql, 'LIMIT') !== false) {
$sql = preg_replace('#LIMIT ([0-9]+),([ 0-9]+)#', 'LIMIT \\2 OFFSET \\1', $sql);
}
if (defined('FORUM_SHOW_QUERIES') || defined('FORUM_DEBUG')) {
$q_start = forum_microtime();
}
@pg_send_query($this->link_id, $sql);
$this->query_result = @pg_get_result($this->link_id);
if (pg_result_status($this->query_result) != PGSQL_FATAL_ERROR) {
if (defined('FORUM_SHOW_QUERIES') || defined('FORUM_DEBUG')) {
$this->saved_queries[] = array($sql, sprintf('%.5f', forum_microtime() - $q_start));
}
++$this->num_queries;
$this->last_query_text[$this->query_result] = $sql;
return $this->query_result;
} else {
if (defined('FORUM_SHOW_QUERIES') || defined('FORUM_DEBUG')) {
$this->saved_queries[] = array($sql, 0);
}
$this->error_msg = @pg_result_error($this->query_result);
if ($this->in_transaction) {
@pg_query($this->link_id, 'ROLLBACK');
}
--$this->in_transaction;
return false;
}
}
开发者ID:mdb-webdev,项目名称:punbb,代码行数:32,代码来源:pgsql.php
示例5: pg_db_send_query
function pg_db_send_query($iConn, $sQry)
{
$iQuery = @pg_send_query($iConn, $sQry);
if (!$iQuery) {
$erro = pg_ErrorMessage($iConn) . "\n" . $sQry;
msgErro($erro);
}
return $iQuery;
}
开发者ID:brunopagno,项目名称:everydayvis,代码行数:9,代码来源:postgresql.php
示例6: executeQuery
function executeQuery($sql_commands)
{
if (!pg_send_query($this->link, $sql_commands)) {
throw new DatabaseException("PostgreSQL database query failed on following query:\n{$sql_commands}");
}
$this->res = pg_get_result($this->link);
DEBUG("DB: Query was: <em>{$sql_commands}</em>");
$this->executedQueries++;
return true;
}
开发者ID:BackupTheBerlios,项目名称:twonineothree-svn,代码行数:10,代码来源:postgresql.php
示例7: query
/**
* Dispatch an unprepared query asynchronously
*
* @param string $query
* @return \Amp\Promise
*/
public function query(string $query) : \Amp\Promise
{
if ($this->queryCacheSize > $this->maxOutstandingQueries) {
return new \Amp\Failure(new \RuntimeException("Too busy"));
}
$deferred = new \Amp\Deferred();
$this->queryCache[] = [self::$OP_QUERY, [$query], $deferred];
$this->queryCacheSize++;
if (!$this->queryCacheSize++) {
$sendResult = \pg_send_query($this->db, $query);
$this->processSendResult($sendResult);
}
return $deferred->promise();
}
开发者ID:amphp,项目名称:pgsql,代码行数:20,代码来源:Connection.php
示例8: rawQuery
public function rawQuery($sql, array $params = [])
{
if (empty($params)) {
pg_send_query($this->dbconn, $sql);
} else {
pg_send_query_params($this->dbconn, $sql, $params);
}
$result = pg_get_result($this->dbconn);
$err = pg_result_error($result);
if ($err) {
throw new \Pg\Exception($err, 0, null, pg_result_error_field($result, PGSQL_DIAG_SQLSTATE));
}
return new \Pg\Statement($result, $this->typeConverter);
}
开发者ID:aoyagikouhei,项目名称:pg,代码行数:14,代码来源:Db.php
示例9: query
function query($strSQL)
{
global $aQueries;
// Save the query.
$aQueries[] = $strSQL;
// Execute the query.
$querySuccess = pg_send_query($this->objConnection, $strSQL);
$this->objResult = @pg_get_result($this->objConnection);
// Return the result.
if ($querySuccess === FALSE) {
DatabaseError();
} else {
return TRUE;
}
}
开发者ID:OvBB,项目名称:v1.0,代码行数:15,代码来源:pgsql.inc.php
示例10: query
function query($sql)
{
@pg_send_query($this->link_id, $sql);
$this->query_result = @pg_get_result($this->link_id);
if (pg_result_status($this->query_result) != PGSQL_FATAL_ERROR) {
++$this->num_queries;
//$this->last_query_text[$this->query_result] = $sql;
return $this->query_result;
} else {
if ($this->in_transaction) {
@pg_query($this->link_id, "ROLLBACK");
}
--$this->in_transaction;
die(error(pg_result_error($this->query_result)));
return false;
}
}
开发者ID:Refuge89,项目名称:World-of-Warcraft-Trinity-Core-MaNGOS,代码行数:17,代码来源:pgsql.php
示例11: query_execute
public function query_execute($sql)
{
// Make sure the database is connected
$this->connect();
if ($result = pg_send_query($this->connection, $sql)) {
$result = pg_get_result($this->connection);
}
if (!is_resource($result)) {
throw new Database_Exception(':error [ :query ]', array(':error' => pg_last_error($this->connection), ':query' => $sql));
}
// Set the last query
$this->last_query = $sql;
if ($this->config['fix_booleans']) {
return Database_Postgresql_Result_Boolean::factory($result, $sql, $this->connection, $this->config['object']);
}
return new Database_Postgresql_Result($result, $sql, $this->connection, $this->config['object']);
}
开发者ID:anqqa,项目名称:Anqh,代码行数:17,代码来源:Database_Postgresql.php
示例12: query
public function query($query)
{
if (!pg_send_query($this->connection, $query)) {
throw $this->createException(pg_last_error($this->connection), 0, NULL);
}
$time = microtime(TRUE);
$resource = pg_get_result($this->connection);
$time = microtime(TRUE) - $time;
if ($resource === FALSE) {
throw $this->createException(pg_last_error($this->connection), 0, NULL);
}
$state = pg_result_error_field($resource, PGSQL_DIAG_SQLSTATE);
if ($state !== NULL) {
throw $this->createException(pg_result_error($resource), 0, $state, $query);
}
$this->affectedRows = pg_affected_rows($resource);
return new Result(new PgsqlResultAdapter($resource), $this, $time);
}
开发者ID:jasir,项目名称:dbal,代码行数:18,代码来源:PgsqlDriver.php
示例13: SQLLoad
function SQLLoad($file)
{
header("SQL: {$file}", false);
$con = db::RawConnection();
$sql = file_get_contents($file);
pg_send_query($con, $sql);
if (($error = pg_last_error($con)) !== '') {
die("Failure at loading {{$file}} with {{$error}}");
}
while (pg_connection_busy($con)) {
sleep(1);
}
while (pg_get_result($con) !== false) {
if (($error = pg_last_error($con)) !== '') {
die("Failure at loading {{$file}} with {{$error}}");
}
}
}
开发者ID:Exsul,项目名称:inyo,代码行数:18,代码来源:loader.php
示例14: db_query
/**
* Does a query with placeholders
*/
function db_query($q)
{
$this->db_connect();
$this->statement_handle = null;
$this->sql = $this->db_merge($q);
// Do the query
$start = microtime(true);
pg_send_query($this->db, $this->sql);
$this->statement_handle = pg_get_result($this->db);
$this->duration = microtime(true) - $start;
ar_logger('SQL: [' . number_format($this->duration, 6) . '] ' . $this->sql, $this->db_connection);
$GLOBALS['db_time'] += $this->duration;
if ($error = pg_result_error($this->statement_handle)) {
$errorstr = 'SQL ERROR: ' . $error . "\nSTATEMENT: " . $this->sql;
//debug($errorstr);
ar_logger($errorstr, $this->db_connection);
throw_error($errorstr);
}
$this->sql = array();
}
开发者ID:esconsut1,项目名称:php-rails-clone,代码行数:23,代码来源:ar_postgresql.php
示例15: ejecutarValidandoUniqueANDPrimaryKey
function ejecutarValidandoUniqueANDPrimaryKey($sql)
{
if ($sql == "") {
return 0;
} else {
/* Si puede enviar la consulta sin importar que encuentre llaves duplicadas */
if (pg_send_query($this->connect, $sql)) {
/* Ejecuta la consulta */
$this->consulta_ID = pg_get_result($this->connect);
/* Se tiene algun resultado sin importar que contenga errores de duplidados */
if ($this->consulta_ID) {
/* Detecte un posible error */
$state = pg_result_error_field($this->consulta_ID, PGSQL_DIAG_SQLSTATE);
/* Si no se genero ningun error */
if ($state == 0) {
return $this->consulta_ID;
} else {
/* Si encontro algun error */
return false;
}
}
}
}
}
开发者ID:johnny9052,项目名称:loguinMasterPagePhpRegistroAjaxDAOPDF,代码行数:24,代码来源:clsConexion.php
示例16: transferDBtoArray
public function transferDBtoArray($host, $user, $password, $db_or_dsn_name, $cndriver = "mysql")
{
$this->m = 0;
if (!$this->connect($host, $user, $password, $db_or_dsn_name, $cndriver)) {
echo "Fail to connect database";
exit(0);
}
if ($this->debugsql == true) {
echo "<textarea cols='100' rows='40'>{$this->sql}</textarea>";
die;
}
if ($cndriver == "odbc") {
$result = odbc_exec($this->myconn, $this->sql);
while ($row = odbc_fetch_array($result)) {
foreach ($this->arrayfield as $out) {
$this->arraysqltable[$this->m]["{$out}"] = $row["{$out}"];
}
$this->m++;
}
} elseif ($cndriver == "psql") {
pg_send_query($this->myconn, $this->sql);
$result = pg_get_result($this->myconn);
while ($row = pg_fetch_array($result, NULL, PGSQL_ASSOC)) {
foreach ($this->arrayfield as $out) {
$this->arraysqltable[$this->m]["{$out}"] = $row["{$out}"];
}
$this->m++;
}
} else {
@mysql_query("set names 'utf8'");
$result = @mysql_query($this->sql);
//query from db
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
foreach ($this->arrayfield as $out) {
$this->arraysqltable[$this->m]["{$out}"] = $row["{$out}"];
}
$this->m++;
}
}
// print_r( $this->arraysqltable);die;
//close connection to db
}
开发者ID:marciocamello,项目名称:qms_entol_net,代码行数:42,代码来源:PHPJasperXML.php
示例17: pg_send_query
$query .= $response->attributes()->shef_id;
$query .= "',";
$query .= $response->attributes()->elev;
$query .= ",";
$query .= $response->attributes()->lat;
$query .= ",";
$query .= $response->attributes()->lon;
$query .= ",'";
$query .= $response->attributes()->ObTime;
$query .= "','";
$query .= $response->attributes()->provider;
$query .= "',";
$query .= $response->attributes()->data_value;
$query .= ",'";
$query .= $response->attributes()->QCD;
$query .= "','";
$query .= $response->attributes()->QCA;
$query .= "','";
$query .= $response->attributes()->QCR;
$query .= "')";
$pgresult = pg_send_query($dbhandle, $query);
$res1 = pg_get_result($dbhandle);
}
echo ' ...UDFCD 24 HourPrecip done! ' . $counter2 . ' records inserted. ' . date("F j, Y, g:i:s a") . '<br />';
}
//call post processing code:
echo '<br />Calling pg function data_processing.madis_daily_process()' . date("F j, Y, g:i:s a") . '<br />';
$query = 'SELECT * FROM data_processing.madis_daily_process()';
$pgresult = pg_send_query($dbhandle, $query);
$res1 = pg_get_result($dbhandle);
echo '<br />Processing ended at ' . date("F j, Y, g:i:s a") . '. ' . $counter1 . ' total records inserted.';
开发者ID:CODeS-Coop,项目名称:UDFCD,代码行数:31,代码来源:udfcd_php_xml_madis_test.php
示例18: query
/**
* Executes a query
*
* @param string $query SQL query
* @param bool $debug False allows the query to not show in debug page
* @author Matthew Lawrence <[email protected]>
* @since 1.1.9
* @return resource Executed query
**/
function query($query, $debug = true)
{
$this->querycount++;
if (isset($this->get['debug']) && $debug) {
$this->debug($query);
}
if (!pg_send_query($this->connection, $query)) {
$err = pg_get_result($this->connection);
error(QUICKSILVER_QUERY_ERROR, pg_result_error($err), $query, 0);
} else {
$this->last = pg_get_result($this->connection);
if (false === $this->last) {
error(QUICKSILVER_QUERY_ERROR, pg_result_error($err), $query, 0);
}
}
return $this->last;
}
开发者ID:BackupTheBerlios,项目名称:qsf-svn,代码行数:26,代码来源:pgsql.php
示例19: doQuery
public function doQuery($sql)
{
if (function_exists('mb_convert_encoding')) {
$sql = mb_convert_encoding($sql, 'UTF-8');
}
$this->mTransactionState->check();
if (pg_send_query($this->mConn, $sql) === false) {
throw new DBUnexpectedError($this, "Unable to post new query to PostgreSQL\n");
}
$this->mLastResult = pg_get_result($this->mConn);
$this->mTransactionState->check();
$this->mAffectedRows = null;
if (pg_result_error($this->mLastResult)) {
return false;
}
return $this->mLastResult;
}
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:17,代码来源:DatabasePostgres.php
示例20: query
/**
* Query the database.
*
* @param string $string The query SQL.
* @param boolean|int $hide_errors 1 if hide errors, 0 if not.
* @param integer $write_query 1 if executes on slave database, 0 if not.
* @return resource The query data.
*/
function query($string, $hide_errors = 0, $write_query = 0)
{
global $mybb;
$string = preg_replace("#LIMIT (\\s*)([0-9]+),(\\s*)([0-9]+)\$#im", "LIMIT \$4 OFFSET \$2", trim($string));
$this->last_query = $string;
get_execution_time();
if (strtolower(substr(ltrim($string), 0, 5)) == 'alter') {
$string = preg_replace("#\\sAFTER\\s([a-z_]+?)(;*?)\$#i", "", $string);
if (strstr($string, 'CHANGE') !== false) {
$string = str_replace(' CHANGE ', ' ALTER ', $string);
}
}
if ($write_query && $this->write_link) {
while (pg_connection_busy($this->write_link)) {
}
$this->current_link =& $this->write_link;
pg_send_query($this->current_link, $string);
$query = pg_get_result($this->current_link);
} else {
while (pg_connection_busy($this->read_link)) {
}
$this->current_link =& $this->read_link;
pg_send_query($this->current_link, $string);
$query = pg_get_result($this->current_link);
}
if (pg_result_error($query) && !$hide_errors) {
$this->error($string, $query);
exit;
}
$query_time = get_execution_time();
$this->query_time += $query_time;
$this->query_count++;
$this->last_result = $query;
if ($mybb->debug_mode) {
$this->explain_query($string, $query_time);
}
return $query;
}
开发者ID:mainhan1804,项目名称:xomvanphong,代码行数:46,代码来源:db_pgsql.php
注:本文中的pg_send_query函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论