本文整理汇总了PHP中mysqli_affected_rows函数的典型用法代码示例。如果您正苦于以下问题:PHP mysqli_affected_rows函数的具体用法?PHP mysqli_affected_rows怎么用?PHP mysqli_affected_rows使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mysqli_affected_rows函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Copyright
/**
|--------------------------------------------------------------------------|
| https://github.com/Bigjoos/ |
|--------------------------------------------------------------------------|
| Licence Info: GPL |
|--------------------------------------------------------------------------|
| Copyright (C) 2010 U-232 V5 |
|--------------------------------------------------------------------------|
| A bittorrent tracker source based on TBDev.net/tbsource/bytemonsoon. |
|--------------------------------------------------------------------------|
| Project Leaders: Mindless, Autotron, whocares, Swizzles. |
|--------------------------------------------------------------------------|
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/ \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \
( U | - | 2 | 3 | 2 )-( S | o | u | r | c | e )-( C | o | d | e )
\_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
*/
function docleanup($data)
{
global $INSTALLER09, $queries, $mc1;
set_time_limit(1200);
ignore_user_abort(1);
//== Delete inactive user accounts
$secs = 350 * 86400;
$dt = TIME_NOW - $secs;
$maxclass = UC_STAFF;
sql_query("SELECT FROM users WHERE parked='no' AND status='confirmed' AND class < {$maxclass} AND last_access < {$dt}");
//== Delete parked user accounts
$secs = 675 * 86400;
// change the time to fit your needs
$dt = TIME_NOW - $secs;
$maxclass = UC_STAFF;
sql_query("SELECT FROM users WHERE parked='yes' AND status='confirmed' AND class < {$maxclass} AND last_access < {$dt}");
if ($queries > 0) {
write_log("Inactive Clean -------------------- Inactive Clean Complete using {$queries} queries--------------------");
}
if (false !== mysqli_affected_rows($GLOBALS["___mysqli_ston"])) {
$data['clean_desc'] = mysqli_affected_rows($GLOBALS["___mysqli_ston"]) . " items deleted/updated";
}
if ($data['clean_log']) {
cleanup_log($data);
}
}
示例2: processQuery
public function processQuery($sql, $type = NULL)
{
$result = mysqli_query($this->db, $sql);
$this->checkForError();
$data = array();
if ($result instanceof mysqli_result) {
$resultType = MYSQLI_NUM;
if ($type == 'assoc') {
$resultType = MYSQLI_ASSOC;
}
while ($row = mysqli_fetch_array($result, $resultType)) {
if (mysqli_affected_rows($this->db) > 1) {
array_push($data, $row);
} else {
$data = $row;
}
}
mysqli_free_result($result);
} else {
if ($result) {
$data = mysqli_insert_id($this->db);
}
}
return $data;
}
示例3: mysql_compat_affected_rows
function mysql_compat_affected_rows($link = NULL)
{
if (!isset($link)) {
$link = $GLOBALS['mysql_compat_last_link'];
}
return mysqli_affected_rows($link);
}
示例4: affectedRow
public function affectedRow()
{
if ($this->con) {
return mysqli_affected_rows($this->con);
}
return 0;
}
示例5: affectedRows
/**
* Return the number of rows affected by a query.
*
* @return integer
*/
public static function affectedRows()
{
if (is_null(self::$conn_id)) {
self::init();
}
return mysqli_affected_rows(self::$conn_id);
}
示例6: docleanup
function docleanup($data)
{
global $INSTALLER09, $queries, $mc1;
set_time_limit(1200);
ignore_user_abort(1);
sql_query("UPDATE `freeslots` SET `addedup` = 0 WHERE `addedup` != 0 AND `addedup` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
sql_query("UPDATE `freeslots` SET `addedfree` = 0 WHERE `addedfree` != 0 AND `addedfree` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
sql_query("DELETE FROM `freeslots` WHERE `addedup` = 0 AND `addedfree` = 0") or sqlerr(__FILE__, __LINE__);
sql_query("UPDATE `users` SET `free_switch` = 0 WHERE `free_switch` > 1 AND `free_switch` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
sql_query("UPDATE `torrents` SET `free` = 0 WHERE `free` > 1 AND `free` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
sql_query("UPDATE `users` SET `downloadpos` = 1 WHERE `downloadpos` > 1 AND `downloadpos` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
sql_query("UPDATE `users` SET `uploadpos` = 1 WHERE `uploadpos` > 1 AND `uploadpos` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
sql_query("UPDATE `users` SET `chatpost` = 1 WHERE `chatpost` > 1 AND `chatpost` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
sql_query("UPDATE `users` SET `avatarpos` = 1 WHERE `avatarpos` > 1 AND `avatarpos` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
sql_query("UPDATE `users` SET `immunity` = 0 WHERE `immunity` > 1 AND `immunity` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
sql_query("UPDATE `users` SET `warned` = 0 WHERE `warned` > 1 AND `warned` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
sql_query("UPDATE `users` SET `pirate` = 0 WHERE `pirate` > 1 AND `pirate` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
sql_query("UPDATE `users` SET `king` = 0 WHERE `king` > 1 AND `king` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
if ($queries > 0) {
write_log("User Clean -------------------- User Clean Complete using {$queries} queries--------------------");
}
if (false !== mysqli_affected_rows($GLOBALS["___mysqli_ston"])) {
$data['clean_desc'] = mysqli_affected_rows($GLOBALS["___mysqli_ston"]) . " items deleted/updated";
}
if ($data['clean_log']) {
cleanup_log($data);
}
}
示例7: insertItems
public function insertItems(Items $items)
{
$con = self::openConnection();
$affected = 0;
mysqli_begin_transaction($con);
$stm = mysqli_stmt_init($con);
$sql = "INSERT INTO category VALUES (?, ?, ?)";
mysqli_stmt_prepare($stm, $sql);
foreach ($items->getItems() as $item) {
$code = $item->getCode();
$name = $item->getName();
$parent = $item->getParent() == null ? null : $item->getParent()->getCode();
mysqli_stmt_bind_param($stm, 'sss', $code, $name, $parent);
mysqli_stmt_execute($stm);
if (mysqli_affected_rows($con) == 1) {
$affected++;
}
}
if ($affected > 0) {
mysqli_commit($con);
} else {
mysqli_rollback($con);
}
return $affected;
}
示例8: insertDepartment
function insertDepartment($name, $manager_id)
{
checkConnectivity2();
$query = sprintf("insert into department(name,manager_id\t) values('%s',%s)", $name, $manager_id);
mysqli_query($GLOBALS['connection_link'], $query);
return mysqli_affected_rows($GLOBALS['connection_link']) > 0;
}
示例9: docleanup
function docleanup($data)
{
global $INSTALLER09, $queries, $mc1;
set_time_limit(0);
ignore_user_abort(1);
//== Delete old backup's
$days = 3;
$res = sql_query("SELECT id, name FROM dbbackup WHERE added < " . sqlesc(TIME_NOW - $days * 86400)) or sqlerr(__FILE__, __LINE__);
if (mysqli_num_rows($res) > 0) {
$ids = array();
while ($arr = mysqli_fetch_assoc($res)) {
$ids[] = (int) $arr['id'];
$filename = $INSTALLER09['backup_dir'] . '/' . $arr['name'];
if (is_file($filename)) {
unlink($filename);
}
}
sql_query('DELETE FROM dbbackup WHERE id IN (' . implode(', ', $ids) . ')') or sqlerr(__FILE__, __LINE__);
}
//== end
if ($queries > 0) {
write_log("Backup Clean -------------------- Backup Clean Complete using {$queries} queries--------------------");
}
if (false !== mysqli_affected_rows($GLOBALS["___mysqli_ston"])) {
$data['clean_desc'] = mysqli_affected_rows($GLOBALS["___mysqli_ston"]) . " items deleted/updated";
}
if ($data['clean_log']) {
cleanup_log($data);
}
}
示例10: executeQuery
/**
* Native function for executing mysql query
*/
private function executeQuery($q)
{
if (empty($q)) {
throw new DBException('Empty query submitted!');
}
if (DB_DEBUG) {
$start = microtime(true);
}
$this->_res_resource = mysqli_query($this->_con, $q);
if (DB_DEBUG) {
$end = microtime(true);
$this->_executedQueries[] = array('q' => $q, 'time' => $end - $start);
}
if (!$this->_res_resource) {
throw new DBException(mysqli_error($this->_con));
}
if (preg_match('/^SELECT.+/', strtoupper($q))) {
$this->_res_num = @mysqli_num_rows($this->_res_resource);
} elseif (preg_match('/^INSERT.+/', strtoupper($q))) {
$this->_last_inserted_id = mysqli_insert_id($this->_con);
$this->_affected_rows = @mysqli_affected_rows($this->_con);
} else {
$this->_affected_rows = @mysqli_affected_rows($this->_con);
}
return true;
}
示例11: ejecutar
public function ejecutar($sql, $conexion)
{
$n = 0;
$resultado = mysqli_query($conexion, $sql);
$n = mysqli_affected_rows($conexion);
return $n;
}
示例12: insertItems
public function insertItems(Items $items)
{
$con = self::openConnection();
$affected = 0;
mysqli_begin_transaction($con);
$stm = mysqli_stmt_init($con);
$sql = "INSERT INTO product VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
mysqli_stmt_prepare($stm, $sql);
foreach ($items->getItems() as $item) {
$code = $item->getCode();
$articul = $item->getArticul();
$name = $item->getName();
$bmuID = $item->getBasicMeasurementUnit() == null ? null : $item->getBasicMeasurementUnit()->getId();
$price = $item->getPrice();
$curID = $item->getCurrency() == null ? null : $item->getCurrency()->getId();
$muID = $item->getMeasurementUnit() == null ? null : $item->getMeasurementUnit()->getId();
$parent = $item->getParent() == null ? null : $item->getParent()->getCode();
mysqli_stmt_bind_param($stm, 'sssdddds', $code, $articul, $name, $bmuID, $price, $curID, $muID, $parent);
mysqli_stmt_execute($stm);
if (mysqli_affected_rows($con) == 1) {
$affected++;
}
}
if ($affected > 0) {
mysqli_commit($con);
} else {
mysqli_rollback($con);
}
return $affected;
}
示例13: query
public function query($sql)
{
$pos = stripos($sql, 'select');
if (is_numeric($pos)) {
//是select 语句
$rs = mysqli_query($this->conn, $sql);
if (mysqli_errno($this->conn)) {
die('you have an error ' . mysqli_error($this->conn));
}
if ($rs === false) {
return mysqli_affected_rows($this->conn);
}
//什么时候返回是false呢...哦子查询是select
$columns = array();
while ($property = @mysqli_fetch_field($rs)) {
$columns[] = $property->name;
}
$arr = array();
while ($result = @mysqli_fetch_row($rs)) {
$arr[] = array_combine($columns, $result);
}
return $arr;
} else {
mysqli_query($this->conn, $sql);
if (mysqli_errno($this->conn)) {
die('you have an error ' . mysqli_error($this->conn));
}
return mysqli_affected_rows($this->conn);
}
}
示例14: Copyright
/**
|--------------------------------------------------------------------------|
| https://github.com/Bigjoos/ |
|--------------------------------------------------------------------------|
| Licence Info: GPL |
|--------------------------------------------------------------------------|
| Copyright (C) 2010 U-232 V4 |
|--------------------------------------------------------------------------|
| A bittorrent tracker source based on TBDev.net/tbsource/bytemonsoon. |
|--------------------------------------------------------------------------|
| Project Leaders: Mindless,putyn. |
|--------------------------------------------------------------------------|
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/ \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \
( U | - | 2 | 3 | 2 )-( S | o | u | r | c | e )-( C | o | d | e )
\_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
*/
function docleanup($data)
{
global $INSTALLER09, $queries, $mc1;
set_time_limit(0);
ignore_user_abort(1);
$deadtime = TIME_NOW - $INSTALLER09['signup_timeout'];
$res = sql_query("SELECT id, username, added, downloaded, uploaded, last_access, class, donor, warned, enabled, status FROM users WHERE status = 'pending' AND added < {$deadtime} AND last_login < {$deadtime} AND last_access < {$deadtime} ORDER BY username DESC");
if (mysqli_num_rows($res) != 0) {
while ($arr = mysqli_fetch_assoc($res)) {
$userid = $arr['id'];
$res_del = sql_query("DELETE FROM users WHERE id=" . sqlesc($userid)) or sqlerr(__FILE__, __LINE__);
$mc1->delete_value('MyUser_' . $userid);
$mc1->delete_value('user' . $userid);
write_log("User: {$arr['username']} Was deleted by Expired Signup clean");
}
}
if ($queries > 0) {
write_log("Expired Signup clean-------------------- Expired Signup cleanup Complete using {$queries} queries --------------------");
}
if (false !== mysqli_affected_rows($GLOBALS["___mysqli_ston"])) {
$data['clean_desc'] = mysqli_affected_rows($GLOBALS["___mysqli_ston"]) . " items deleted/updated";
}
if ($data['clean_log']) {
cleanup_log($data);
}
}
示例15: scrape
function scrape($url, $infohash = '')
{
global $TABLE_PREFIX, $BASEDIR;
if (isset($url)) {
$url_c = parse_url($url);
if (!isset($url_c["port"]) || empty($url_c["port"])) {
$url_c["port"] = 80;
}
require_once $BASEDIR . "/phpscraper/" . $url_c["scheme"] . "tscraper.php";
try {
$timeout = 5;
if ($url_c["scheme"] == "udp") {
$scraper = new udptscraper($timeout);
} else {
$scraper = new httptscraper($timeout);
}
$ret = $scraper->scrape($url_c["scheme"] . "://" . $url_c["host"] . ":" . $url_c["port"] . ($url_c["scheme"] == "udp" ? "" : "/announce"), array($infohash));
do_sqlquery("UPDATE `{$TABLE_PREFIX}files` SET `lastupdate`=NOW(), `lastsuccess`=NOW(), `seeds`=" . $ret[$infohash]["seeders"] . ", `leechers`=" . $ret[$infohash]["leechers"] . ", `finished`=" . $ret[$infohash]["completed"] . " WHERE `announce_url` = '" . $url . "'" . ($infohash == "" ? "" : " AND `info_hash`='" . $infohash . "'"), true);
if (mysqli_affected_rows($GLOBALS["___mysqli_ston"]) == 1) {
write_log('SUCCESS update external torrent from ' . $url . ' tracker (infohash: ' . $infohash . ')', '');
}
} catch (ScraperException $e) {
write_log("FAILED update external torrent " . ($infohash == "" ? "" : "(infohash: " . $infohash . ")") . " from " . $url . " tracker (" . $e->getMessage() . "))", "");
}
return;
}
return;
}