本文整理匯總了PHP中core\Database::fetchRow方法的典型用法代碼示例。如果您正苦於以下問題:PHP Database::fetchRow方法的具體用法?PHP Database::fetchRow怎麽用?PHP Database::fetchRow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類core\Database
的用法示例。
在下文中一共展示了Database::fetchRow方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: IFNULL
$res = (int) Database::fetchField('SELECT IFNULL(SUM(`capacity`), 0) as occupation
FROM `' . FRAMEWORK_COLLECTION_PROCESS . '`
WHERE `pid` IS NOT NULL AND `pid` > 0');
Database::unlockTables(true);
if ($res >= $capLimit) {
Log::debug('Active processes has occupied maximum server capacity, daemon exits.');
Database::rollback();
die;
}
unset($res, $capLimit);
Database::lockTables(array(FRAMEWORK_COLLECTION_PROCESS . ' LOW_PRIORITY WRITE', FRAMEWORK_COLLECTION_PROCESS . ' as `active` LOW_PRIORITY WRITE', FRAMEWORK_COLLECTION_PROCESS . ' as `inactive` LOW_PRIORITY WRITE'));
$process = Database::fetchRow('SELECT `inactive`.* FROM `' . FRAMEWORK_COLLECTION_PROCESS . '` as `inactive`
LEFT JOIN ( SELECT `type`, SUM(`capacity`) as `occupation` FROM `' . FRAMEWORK_COLLECTION_PROCESS . '`
WHERE `pid` IS NOT NULL GROUP BY `type` ) as `active`
ON `active`.`type` = `inactive`.`type`
WHERE `timestamp` <= CURRENT_TIMESTAMP
AND `start_time` <= CURRENT_TIMESTAMP
AND `inactive`.`pid` IS NULL
ORDER BY `occupation`, `weight` DESC, `id`
LIMIT 1;');
// No waiting jobs in queue.
if (!$process) {
Database::unlockTables(true);
Database::rollback();
Log::debug('No more jobs to do, suicide.');
die;
}
$processContents = (array) ContentDecoder::json($process[Node::FIELD_VIRTUAL], 1);
unset($process[Node::FIELD_VIRTUAL]);
$process += $processContents;
unset($processContents);