本文整理汇总了PHP中IDatabase::query方法的典型用法代码示例。如果您正苦于以下问题:PHP IDatabase::query方法的具体用法?PHP IDatabase::query怎么用?PHP IDatabase::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDatabase
的用法示例。
在下文中一共展示了IDatabase::query方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initConnection
protected function initConnection($lockDb, IDatabase $db)
{
# Let this transaction see lock rows from other transactions
$db->query("SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;");
# Do everything in a transaction as it all gets rolled back eventually
$db->startAtomic(__CLASS__);
}
示例2: 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;
}
示例3: query
/**
* 执行一条SQL语句
* @param $sql
* @return \Swoole\Database\MySQLiRecord
*/
public function query($sql)
{
if ($this->debug) {
echo "{$sql}<br />\n<hr />";
}
$this->read_times += 1;
return $this->_db->query($sql);
}
示例4: desc
/**
* 获取表的字段描述
* @return array
*/
function desc()
{
return $this->db->query('describe ' . $this->table)->fetchall();
}
示例5: initConnection
/**
* @param string $lockDb
* @param IDatabase $db
*/
protected function initConnection($lockDb, IDatabase $db)
{
# Let this transaction see lock rows from other transactions
$db->query("SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;");
}
示例6: badLockingMethodImplicit
private function badLockingMethodImplicit(IDatabase $db)
{
$lock = $db->getScopedLockAndFlush('meow', __METHOD__, 1);
$db->query("SELECT 1");
// trigger DBO_TRX
throw new RunTimeException("Uh oh!");
}
示例7: sqlDoQuery
protected function sqlDoQuery(IDatabase $db, $line, $dieOnError)
{
try {
$res = $db->query($line);
$this->sqlPrintResult($res, $db);
} catch (DBQueryError $e) {
$this->error($e, $dieOnError);
}
}