本文整理汇总了PHP中core\Database::query方法的典型用法代码示例。如果您正苦于以下问题:PHP Database::query方法的具体用法?PHP Database::query怎么用?PHP Database::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core\Database
的用法示例。
在下文中一共展示了Database::query方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: listUsers
/**
* @return string
*/
public static function listUsers(Database &$database)
{
$query = $database->query('SELECT name, email FROM users');
$table = '<table><tr><th>Name</th><th>E-mail</th></tr>';
while ($value = $query->fetch(Database::FETCH_BOTH)) {
$table .= '<tr><td>' . $value[0] . '</td><td>' . $value[1] . '</td></tr>';
}
$table .= '</table>';
return $table;
}
示例2: stream_get_contents
// Log the process output if available
$stdout = stream_get_contents($pipes[1]);
$stderr = stream_get_contents($pipes[2]);
if ("{$stdout}{$stderr}") {
$method = $stderr ? 'error' : 'info';
Log::$method(sprintf('Output captured from command line: %s', $process['command']), array_filter(array('stdout' => $stdout, 'stderr' => $stderr)));
unset($method);
}
unset($stdout, $stderr);
// Handles cleanup after process exit
switch (strtolower($process['type'])) {
// Permanent processes will be restarted upon death
case 'permanent':
core\Database::query('UPDATE `' . FRAMEWORK_COLLECTION_PROCESS . '` SET `pid` = NULL WHERE `id` = ?', $process['id']);
Log::debug('Permanent process died, clearing pid.', [$res, $process]);
break;
// Sets pid to 0, prevents it fire again and double enqueue of the same time slot.
// Sets pid to 0, prevents it fire again and double enqueue of the same time slot.
case 'cron':
core\Database::query('UPDATE `' . FRAMEWORK_COLLECTION_PROCESS . '` SET `pid` = 0 WHERE `id` = ?', $process['id']);
break;
// Deletes the process object upon exit
// Deletes the process object upon exit
default:
$process = array_select($process, array(Node::FIELD_COLLECTION, 'id', 'pid'));
$res = Node::delete($process);
Log::debug("Deleting finished process, affected rows: {$res}.", [$res, $process]);
break;
}
// Recursive process, spawn another worker.
Process::spawnWorker(@$_SERVER['env']);
示例3: invalidate
/**
* Logout function, application terminating point.
*/
static function invalidate($sid = null)
{
if ($sid === null) {
$sid = static::$currentSession['sid'];
}
$sid = util::packUuid($sid);
$session = Node::getOne(array(Node::FIELD_COLLECTION => FRAMEWORK_COLLECTION_SESSION, 'sid' => $sid));
Database::query('DELETE FROM `' . FRAMEWORK_COLLECTION_SESSION . '` WHERE `sid` = ?', array($sid));
Log::info(sprintf('Session invalidated', $session));
/* Clear reference */
static::$currentSession = null;
}