本文整理汇总了PHP中IDatabase::getLag方法的典型用法代码示例。如果您正苦于以下问题:PHP IDatabase::getLag方法的具体用法?PHP IDatabase::getLag怎么用?PHP IDatabase::getLag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDatabase
的用法示例。
在下文中一共展示了IDatabase::getLag方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: safeGetLag
/**
* Get the lag in seconds for a given connection, or zero if this load
* balancer does not have replication enabled.
*
* This should be used in preference to Database::getLag() in cases where
* replication may not be in use, since there is no way to determine if
* replication is in use at the connection level without running
* potentially restricted queries such as SHOW SLAVE STATUS. Using this
* function instead of Database::getLag() avoids a fatal error in this
* case on many installations.
*
* @param IDatabase $conn
* @return int|bool Returns false on error
*/
public function safeGetLag(IDatabase $conn)
{
if ($this->getServerCount() == 1) {
return 0;
} else {
return $conn->getLag();
}
}