本文整理汇总了PHP中SelectQuery::fetchColumn方法的典型用法代码示例。如果您正苦于以下问题:PHP SelectQuery::fetchColumn方法的具体用法?PHP SelectQuery::fetchColumn怎么用?PHP SelectQuery::fetchColumn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SelectQuery
的用法示例。
在下文中一共展示了SelectQuery::fetchColumn方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: remember
public static function remember($user)
{
//We need a user, but we won't remember the admin user.
//if ($user && $user->id > 0 && !in_array('superadmin', $user->roles)) {
if ($user && $user->id > 0) {
$random = get_random('number');
$persist = new PersistUserObj();
$data = array('user_id' => $user->id, 'random' => $random);
if ($persist->create($data)) {
$query = new SelectQuery('PersistUser');
$query->field('MD5(CONCAT(`id`, `user_id`, `random`))')->filter('`id`= :id');
$hash = $query->fetchColumn(array(':id' => $persist->array['id']));
if (setcookie('remembered', $hash, time() + 60 * 60 * 24 * 14, WEB_SUB_FOLDER)) {
return true;
} else {
Backend::addError('Could not set cookie to remember login');
$query = new DeleteQuery('PersistUser');
$query->filter('`id` = :id')->limit(1);
$query->execute(array(':id' => $persist->array['id']));
}
} else {
Backend::addError('Could not remember login');
}
} else {
Backend::addError('Invalid user to remember');
}
return false;
}
示例2: assign
public static function assign($role_id, $access_type, $access_id)
{
$result = false;
//if (!self::barredRole($role)) {
if (!is_numeric($role_id)) {
$role_id = Role::retrieve($role_id);
$role_id = $role_id['id'];
}
$params = array(':role_id' => $role_id, ':access_type' => $access_type, ':access_id' => $access_id);
$query = new SelectQuery('Assignment');
$query->filter('`role_id`= :role_id')->filter('`access_type` = :access_type')->filter('`access_id` = :access_id');
$id = $query->fetchColumn($params);
if ($id) {
$result = true;
} else {
$keys = array('role_id', 'access_type', 'access_id');
$data = array_combine($keys, array_values($params));
$query = new InsertQuery('Assignment');
$query->data($data);
$result = $query->execute() ? true : false;
}
//}
return $result;
}
示例3: userVisits
public static function userVisits($user_id)
{
$query = new SelectQuery('BackendRequest');
$query->field('COUNT(*) AS `visits`')->filter('`user_id` = :user_id')->group('`user_id`');
return $query->fetchColumn(array(':user_id' => $user_id));
}
示例4: hook_init
public static function hook_init()
{
//Check for any system locks
$query = new SelectQuery('BackendLock');
$query->field('`name`')->filter('`type` = :type')->filter('`locked` = 1')->filter('`expire` > NOW()');
while ($lock_name = $query->fetchColumn(array(':type' => self::LOCK_SYSTEM))) {
$lock = BackendLock::retrieve($lock_name, 'dbobject');
if (!$lock->check()) {
//A Lock isn't available, so the request must be aborted.
Controller::whoops('Service Unavailable', array('message' => 'System Offline until ' . $lock->array['expire'] . '. Locked under ' . $lock->array['name'], 'code_hint' => 503));
header('X-Backend-Lock: ' . $lock->array['name']);
header('X-Backend-Lock-Expire: ' . $lock->array['expire']);
}
}
}