本文整理汇总了PHP中IDatabase::fetchObject方法的典型用法代码示例。如果您正苦于以下问题:PHP IDatabase::fetchObject方法的具体用法?PHP IDatabase::fetchObject怎么用?PHP IDatabase::fetchObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDatabase
的用法示例。
在下文中一共展示了IDatabase::fetchObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getWeightScale
protected function getWeightScale($index, IDatabase $conn = null)
{
if (!$conn) {
return 0.0;
}
$weight = 1.0;
if ($this->warmCacheRatio > 0) {
$res = $conn->query('SHOW STATUS', false);
$s = $res ? $conn->fetchObject($res) : false;
if ($s === false) {
$host = $this->parent->getServerName($index);
$this->replLogger->error(__METHOD__ . ": could not get status for {$host}");
} else {
// http://dev.mysql.com/doc/refman/5.7/en/server-status-variables.html
if ($s->Innodb_buffer_pool_pages_total > 0) {
$ratio = $s->Innodb_buffer_pool_pages_data / $s->Innodb_buffer_pool_pages_total;
} elseif ($s->Qcache_total_blocks > 0) {
$ratio = 1.0 - $s->Qcache_free_blocks / $s->Qcache_total_blocks;
} else {
$ratio = 1.0;
}
// Stop caring once $ratio >= $this->warmCacheRatio
$weight *= min($ratio / $this->warmCacheRatio, 1.0);
}
}
return $weight;
}
示例2: countItems
/**
* Count the number of items on a user's watchlist
*
* @param IDatabase $dbr A database connection
* @return int
*/
protected function countItems($dbr)
{
# Fetch the raw count
$rows = $dbr->select('watchlist', array('count' => 'COUNT(*)'), array('wl_user' => $this->getUser()->getId()), __METHOD__);
$row = $dbr->fetchObject($rows);
$count = $row->count;
return floor($count / 2);
}