本文整理汇总了PHP中pg_affected_rows函数的典型用法代码示例。如果您正苦于以下问题:PHP pg_affected_rows函数的具体用法?PHP pg_affected_rows怎么用?PHP pg_affected_rows使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pg_affected_rows函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: affected
function affected()
{
if (is_null($this->affected)) {
$this->affected = pg_affected_rows($this->q);
}
return $this->affected;
}
示例2: affectedRows
public function affectedRows()
{
if (!is_resource($this->result)) {
return false;
}
return pg_affected_rows($this->result);
}
示例3: execute
function execute()
{
$this->queryId = parent::execute();
if (is_resource($this->queryId)) {
return pg_affected_rows($this->queryId);
}
}
示例4: comprobar_operacion
function comprobar_operacion($res, &$error)
{
if (pg_affected_rows($res) == 0) {
$error[] = "No se ha podido modificar el artículo.";
throw new Exception();
}
}
示例5: __construct
public function __construct($result, $sql, $as_object = FALSE, $params = NULL, $total_rows = NULL)
{
parent::__construct($result, $sql, $as_object, $params);
if ($as_object === TRUE) {
$this->_as_object = 'stdClass';
}
if ($total_rows !== NULL) {
$this->_total_rows = $total_rows;
} else {
switch (pg_result_status($result)) {
case PGSQL_TUPLES_OK:
$this->_total_rows = pg_num_rows($result);
break;
case PGSQL_COMMAND_OK:
$this->_total_rows = pg_affected_rows($result);
break;
case PGSQL_BAD_RESPONSE:
case PGSQL_NONFATAL_ERROR:
case PGSQL_FATAL_ERROR:
throw new Database_Exception(':error [ :query ]', array(':error' => pg_result_error($result), ':query' => $sql));
case PGSQL_COPY_OUT:
case PGSQL_COPY_IN:
throw new Database_Exception('PostgreSQL COPY operations not supported [ :query ]', array(':query' => $sql));
default:
$this->_total_rows = 0;
}
}
}
示例6: affected_rows
public function affected_rows()
{
if ($this->last_execute_result === null) {
return 0;
}
return pg_affected_rows($this->last_execute_result);
}
示例7: updateAffectedRows
protected function updateAffectedRows($result)
{
$this->affected_rows += pg_affected_rows($result);
if ($this->affected_rows != 0 && $this->affected_rows % 500 == 0) {
echo get_class($this) . " has affected " . $this->affected_rows . " row(s)...\n";
}
}
示例8: SetData
public function SetData($setQuery)
{
$this->Connect();
//var_dump('????', $setQuery, "???");
$result = pg_query($this->connectionHandle, $setQuery);
return pg_affected_rows($result);
}
示例9: sqlQuery
function sqlQuery($query)
{
if (!$query) {
return false;
}
if (b1n_DEBUG) {
echo '<pre style="text-align: left">QUERY: ' . $query . '</pre>';
}
if (!$this->sqlIsConnected()) {
user_error('DB NOT CONNECTED');
return false;
}
$result = pg_query($this->sqlGetLink(), $query);
if (is_bool($result)) {
return pg_affected_rows($result);
}
$num = pg_num_rows($result);
if ($num > 0) {
for ($i = 0; $i < $num; $i++) {
$row[$i] = pg_fetch_array($result, $i, PGSQL_ASSOC);
}
return $row;
}
return true;
}
示例10: castResult
public static function castResult($result, array $a, Stub $stub, $isNested)
{
$a['num rows'] = pg_num_rows($result);
$a['status'] = pg_result_status($result);
if (isset(self::$resultStatus[$a['status']])) {
$a['status'] = new ConstStub(self::$resultStatus[$a['status']], $a['status']);
}
$a['command-completion tag'] = pg_result_status($result, PGSQL_STATUS_STRING);
if (-1 === $a['num rows']) {
foreach (self::$diagCodes as $k => $v) {
$a['error'][$k] = pg_result_error_field($result, $v);
}
}
$a['affected rows'] = pg_affected_rows($result);
$a['last OID'] = pg_last_oid($result);
$fields = pg_num_fields($result);
for ($i = 0; $i < $fields; ++$i) {
$field = array('name' => pg_field_name($result, $i), 'table' => sprintf('%s (OID: %s)', pg_field_table($result, $i), pg_field_table($result, $i, true)), 'type' => sprintf('%s (OID: %s)', pg_field_type($result, $i), pg_field_type_oid($result, $i)), 'nullable' => (bool) pg_field_is_null($result, $i), 'storage' => pg_field_size($result, $i) . ' bytes', 'display' => pg_field_prtlen($result, $i) . ' chars');
if (' (OID: )' === $field['table']) {
$field['table'] = null;
}
if ('-1 bytes' === $field['storage']) {
$field['storage'] = 'variable size';
} elseif ('1 bytes' === $field['storage']) {
$field['storage'] = '1 byte';
}
if ('1 chars' === $field['display']) {
$field['display'] = '1 char';
}
$a['fields'][] = new EnumStub($field);
}
return $a;
}
示例11: 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";
}
}
示例12: __construct
/**
* @param resource from pg_query() or pg_get_result()
* @param string SQL used to create this result
* @param resource from pg_connect() or pg_pconnect()
* @param boolean|string
* @return void
*/
public function __construct($result, $sql, $link, $return_objects)
{
// PGSQL_COMMAND_OK <- SET client_encoding = 'utf8'
// PGSQL_TUPLES_OK <- SELECT table_name FROM information_schema.tables
// PGSQL_COMMAND_OK <- INSERT INTO pages (name) VALUES ('gone soon')
// PGSQL_COMMAND_OK <- DELETE FROM pages WHERE id = 2
// PGSQL_COMMAND_OK <- UPDATE pb_users SET company_id = 1
// PGSQL_FATAL_ERROR <- SELECT FROM pages
switch (pg_result_status($result)) {
case PGSQL_EMPTY_QUERY:
$this->total_rows = 0;
break;
case PGSQL_COMMAND_OK:
$this->total_rows = pg_affected_rows($result);
break;
case PGSQL_TUPLES_OK:
$this->total_rows = pg_num_rows($result);
break;
case PGSQL_COPY_OUT:
case PGSQL_COPY_IN:
Kohana_Log::add('debug', 'PostgreSQL COPY operations not supported');
break;
case PGSQL_BAD_RESPONSE:
case PGSQL_NONFATAL_ERROR:
case PGSQL_FATAL_ERROR:
throw new Database_Exception(':error [ :query ]', array(':error' => pg_result_error($result), ':query' => $sql));
}
$this->link = $link;
$this->result = $result;
$this->return_objects = $return_objects;
$this->sql = $sql;
}
示例13: Afficher
public function Afficher()
{
if (isset($_SESSION["compte"]) && !empty($_SESSION["compte"])) {
// - gestion spécifique de la page
$account_id = $_SESSION['compte']->id;
$djun_name = $_SESSION['djun_choisi']->nom;
// - On supprime le D'jun
$sql = "DELETE FROM \"libertribes\".\"AVATAR\" WHERE compte_id = {$account_id} and avatar_nom ='{$djun_name}'";
$result = $this->db_connexion->Requete($sql);
if (!$result || pg_affected_rows($result) == 0) {
// - redirection vers la page djun_suppression avec un message d'erreur
header('Location: index.php?page=djun_suppression&erreur=1');
exit;
}
// restructurer la variable de session avatar s'il y a plusieurs avatars
$avatars = array();
$i = 0;
foreach ($_SESSION['avatars'] as $avatar) {
if ($avatar->nom != $_SESSION['djun_choisi']->nom) {
$avatars[$i] = $avatar;
$i++;
}
}
unset($_SESSION['avatars']);
$_SESSION['avatars'] = $avatars;
unset($_SESSION['djun_choisi']);
unset($_SESSION["avatar_name"]);
// - redirection vers la page TDB
header('Location: index.php?page=tdb');
} else {
header('Location: index.php?page=connexion&erreur=3');
exit;
}
}
示例14: query
public function query($string = '')
{
if ($string != '') {
$this->query = $this->escape($string);
} else {
$this->query = $this->select . $this->insert . $this->update . $this->delete . $this->create . $this->from . $this->join . $this->where . $this->group . $this->order . $this->limit;
}
$this->insert = " RETURNING id";
$this->result = pg_exec($this->connection, $this->query);
$this->inserted_id = $this->result;
$this->error = pg_errormessage($this->connection);
$this->affected_rows = pg_affected_rows($this->result);
$this->select = '';
$this->insert = '';
$this->update = '';
$this->delete = '';
$this->create = '';
$this->from = '';
$this->join = '';
$this->where = '';
$this->group = '';
$this->order = '';
$this->limit = '';
return $this;
}
示例15: rowsAffected
public function rowsAffected($result)
{
$affectedRows = pg_affected_rows($result);
if (!$affectedRows) {
$affectedRows = pg_num_rows($result);
}
return $affectedRows;
}