本文整理汇总了PHP中Query::assocParam方法的典型用法代码示例。如果您正苦于以下问题:PHP Query::assocParam方法的具体用法?PHP Query::assocParam怎么用?PHP Query::assocParam使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Query
的用法示例。
在下文中一共展示了Query::assocParam方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doSearch
protected function doSearch(PostArrayAdapter $params)
{
/*
* Параметры
*/
$process = $params->int('process');
$action = $params->int('action');
$actionParent = $params->int('parent_action');
$dateFrom = $params->int('date_from');
$dateTo = $params->int('date_to');
/*
* Запрос
*/
$what[] = 'id_rec';
$what[] = 'concat(ifnull(id_user, ""), concat("/", id_user_authed)) as user_authed';
$what[] = 'dt_event';
$what[] = 'n_action';
$what[] = 'v_data';
$what[] = 'b_encoded';
$where['id_process'] = $process;
if ($actionParent) {
$where['id_rec_parent'] = $actionParent;
}
if ($action) {
$where['n_action'] = $action;
}
if ($dateFrom) {
$where[] = Query::assocParam('dt_event', $dateFrom, true, '>=');
}
if ($dateTo) {
$where[] = Query::assocParam('dt_event', $dateTo, true, '<=');
}
$order = 'dt_event asc, id_rec asc';
$limit = 500;
/*
* Работа с данными
*/
$query = Query::select($what, 'ps_audit', $where, null, $order, $limit);
$result = PSDB::getArray($query);
foreach ($result as &$row) {
//Декодируем действие
$row['n_action'] = BaseAudit::getByCode($process)->decodeAction($row['n_action'], false);
//Декодируем данные
$encoded = 1 * $row['b_encoded'];
if ($encoded) {
$row['v_data'] = print_r(BaseAudit::decodeData($row['v_data']), true);
}
unset($row['b_encoded']);
}
$results = new SearchResults($result, $query);
$results->addSetting('v_data', SearchResults::COL_PRE);
$results->addSetting('n_action', SearchResults::COL_NOWRAP);
return $results;
}
示例2: getProcessStatistic
/**
* Метод загражает карту 'код процесса' => 'код действия' => 'кол-во записей'
*
* @return array
*/
public function getProcessStatistic($dateTo)
{
$where = array();
if ($dateTo) {
$where[] = Query::assocParam('dt_event', $dateTo, true, '<=');
}
$result = array();
foreach ($this->getArray(Query::select('id_process, n_action, count(1) as cnt', 'ps_audit', $where, 'id_process, n_action')) as $rec) {
$result[$rec['id_process']][$rec['n_action']] = $rec['cnt'];
}
return $result;
}
示例3: createUser
/**
* Создание пользователя
* @return int userId - код нового пользователя
*/
public final function createUser(RegFormData $data)
{
$email = PsCheck::email($data->getUserMail());
//Проверим, что пользователь с таким email ещё не заведён
check_condition(!$this->hasMail($email), "Пользователь с почтой [{$email}] уже зарегистрирован");
//Подготовим поля для вставки
$params[self::FIELD_NAME] = $data->getUserName();
$params[self::FIELD_SEX] = $data->getSex();
$params[self::FIELD_EMAIL] = $email;
$params[self::FIELD_PASSWD] = self::hashPassword($data->getPassword());
$params[self::FIELD_B_ADMIN] = 0;
$params[self::FIELD_B_CAN_LOGIN] = 1;
$params[] = Query::assocParam(self::FIELD_DT_REG, 'UNIX_TIMESTAMP()', false);
//Выполняем вставку
$userId = $this->register($this->insert(Query::insert('users', $params)));
//Сохраним данные пользователя в аудит
UserAudit::inst()->afterRegistered($userId, array_filter_keys($this->getUserDataById($userId), self::$SKIP_AUDIT_ON_CREATE_FIELDS));
//Возвращаем код пользователя
return $userId;
}
示例4: executeImpl
protected function executeImpl(ArrayAdapter $params)
{
$action = $params->str('action');
$date = $params->int('date');
$res = array();
switch ($action) {
case 'search':
$res = AdminAuditTools::getAuditStatistic($date);
break;
case 'dump':
$where[] = Query::assocParam('dt_event', $date, true, '<=');
$order[] = 'dt_event asc';
$zipDi = AdminTableDump::dumpTable('id_rec', 'ps_audit', $where, $order);
check_condition($zipDi instanceof DirItem, 'Ошибка снятия дампа. Смотрите лог для деталей.');
$res['path'] = $zipDi->getAbsPath();
break;
case 'load-dumps':
$res['dumps'] = AP_APAudit::getInstance()->getAuditDumpsInfo();
break;
default:
raise_error("Unknown action: {$action}");
}
return new AjaxSuccess($res);
}
示例5: getPostsBeforPost
public function getPostsBeforPost($postId, $limit)
{
return $this->loadPosts('id_post, dt_publication', is_inumeric($postId) ? Query::assocParam('dt_publication', "(select i.dt_publication from {$this->postsView} i where i.id_post=?)", false, '<', array($postId)) : null, array('dt_publication desc', 'id_post desc'), $limit);
}
示例6: loadMsgsPortion
/**
* Метод загружает порцию сообщений - используется как для построения дерева, так и для дозагрузки сообщений в ветку.
*/
public function loadMsgsPortion($threadId = null, $maxCount = -1, $upDown = true, $rootId = null, &$bHasMore = false)
{
$where = array();
if (is_inumeric($rootId)) {
$where[] = Query::assocParam('id_root', $rootId, true, $upDown ? '>' : '<');
}
if ($this->threadIdColumn) {
$where[] = "{$this->threadIdColumn} is not null";
$where[$this->threadIdColumn] = $threadId;
}
$orderRoot = 'id_root ' . ($upDown ? 'asc' : 'desc');
$orderMsgs = array('dt_event asc', $this->idColumn . ' asc');
$order = array($orderRoot, $orderMsgs);
$limit = null;
if ($maxCount > 0) {
$groups = $this->getArray(Query::select('count(1) as cnt, id_root', $this->table, $where, 'id_root', $orderRoot, $maxCount + 1));
$groupNum = 0;
$groupsCnt = count($groups);
foreach ($groups as $group) {
++$groupNum;
//$rootId = $group['id_root'];
$limit = ($limit ? $limit : 0) + (int) $group['cnt'];
if ($limit >= $maxCount) {
$bHasMore = $groupsCnt > $groupNum;
break;
}
}
}
//Мы вычислили лимит, теперь можно и загрузить сообщения
return $this->loadMessages(Query::select('*', $this->table, $where, null, $order, $limit));
}