本文整理汇总了PHP中Query::select方法的典型用法代码示例。如果您正苦于以下问题:PHP Query::select方法的具体用法?PHP Query::select怎么用?PHP Query::select使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Query
的用法示例。
在下文中一共展示了Query::select方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testShouldReturnQueryInstanceWithSelect
public function testShouldReturnQueryInstanceWithSelect()
{
$query = new Query('users');
$expected = 'Query';
$result = $query->select(array('username', 'password'));
$this->assertInstanceOf($expected, $result);
}
示例2: _get
/**
* Get an array of models from the database.
*
* @param array $columns
* @return array
*/
private function _get($columns = array('*'))
{
if (is_null($this->query->selects)) {
$this->query->select($columns);
}
return Hydrator::hydrate($this);
}
示例3: getPointById
/**
* Возвращает очки по коду
*
* @param int|null $userId - если передан код пользователя, то стсиема убедится, что очки даны этому пользователю
* @return UserPointDO
*/
public function getPointById($pointId, $userId = null)
{
$where['id_point'] = $pointId;
if (is_inumeric($userId)) {
$where['id_user'] = $userId;
}
return new UserPointDO($this->getRecEnsure(Query::select('*', 'ps_user_points', $where)));
}
示例4: 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;
}
示例5: getMailCiudadanoRespuestas
function getMailCiudadanoRespuestas($id)
{
include_once "Query.inc";
$query = new Query();
$registros = $query->select("mailCiudadano", "oficio", "idOficio={$id}");
if ($registros) {
foreach ($registros as $reg) {
return array("mailCiudadano" => "{$reg->mailCiudadano}");
}
}
}
示例6: getElectives
static function getElectives($program, $elective_type, $elective_group, $exclude = [])
{
$results = array();
foreach (explode("|", $elective_group) as $group) {
$q = new Query("electives");
$q->select("course_code");
$q->where("program_id=?\n\t\t\t\t\t\t\tAND elective_type=?\n\t\t\t\t\t\t\tAND note=?\n\t\t\t\t\t\t\tAND course_code NOT IN " . Query::valuelistsql($exclude), array_merge([$program, $elective_type, $group], $exclude));
$results = array_merge($results, $q->executeFetchAll());
}
return $results;
}
示例7: 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;
}
示例8: getCateName
/**
* 根据分类id获取分类名
* @param type $id
* @param type $level
* @return type
*/
public static function getCateName($id, $level = null)
{
$query = new Query(Yii::app()->db);
$query->select('name');
$query->from('groupon_cates');
$query->andWhere('id=:id', array(':id' => $id));
if ($level) {
$query->andWhere('level=:level', array(':level' => $level));
}
$name = $query->queryScalar();
return $name;
}
示例9: getQuery
public function getQuery()
{
$query = new Query(Yii::app()->db);
$query->select('id,biz_id,name,city_id,area_id,is_reservation');
$query->from('groupon_biz_shop');
if ($this->biz_id) {
$query->andWhere('biz_id=:bid', array(':bid' => $this->biz_id));
}
if ($this->name) {
$query->andWhere(array('like', 'name', '%' . $this->name . '%'));
}
return $query;
}
示例10: getVisibleObjects
/**
* Метод возвращает видимые пользователю объекты из базы
*/
public function getVisibleObjects(FoldedResources $folded, $objName, array $visibleIdents)
{
$folded->assertWorkWithTable();
$cacheKey = $folded->getUnique("visible-{$objName}");
if (!$this->CACHE->has($cacheKey)) {
$view = $folded->getTableView();
$colIdent = $folded->getTableColumnIdent();
$colStype = $folded->getTableColumnStype();
$where = array();
if ($colStype) {
$where[$colStype] = $folded->getFoldingSubType();
}
$this->CACHE->set($cacheKey, $this->getArray(Query::select('*', $view, $where), null, ObjectQueryFetcher::inst($objName, $colIdent)->setIncludeKeys($visibleIdents)));
}
return $this->CACHE->get($cacheKey);
}
示例11: process
public function process($get, $post)
{
$this->pageData["Title"] = "Home";
// Select all of the courses that this user is already added or ignored
$query = new Query('action');
$result = $query->select('*', array(array('session_id', '=', $_COOKIE['sessionId'])));
$idsAlreadyAdded = array();
foreach ($result as $action) {
array_push($idsAlreadyAdded, $action->get('course_id'));
}
// Generate all of the courses (for testing)
$allCourses = array();
$query = new Query('courses');
$result = $query->select('*', '', array('number', 'ASC'), 20, false);
while ($row = mysqli_fetch_array($result)) {
try {
$course = new Course();
$course->findById($row['id']);
if (!in_array($course->get('id'), $idsAlreadyAdded)) {
// Check that this course has not been added by the user yet
array_push($allCourses, array('id' => $course->get('id'), 'name' => ucwords(strtolower($course->get('name'))), 'department_id' => $course->get('department_id'), 'number' => $course->get('number'), 'description' => strlen($course->get('description')) == 0 ? 'No description' : $course->get('description')));
}
} catch (Exception $e) {
}
}
$this->pageData['allCourses'] = $allCourses;
// Select all of the courses that this user is already added
$query = new Query('action');
$result = $query->select('*', array(array('session_id', '=', $_COOKIE['sessionId']), array('choice', '=', 0)));
$idsAlreadyAdded = array();
foreach ($result as $action) {
array_push($idsAlreadyAdded, $action->get('course_id'));
}
// Get all of the courses in this user's session
$usersCourses = array();
foreach ($idsAlreadyAdded as $courseId) {
try {
$course = new Course();
$course->findById($courseId);
array_push($usersCourses, array('id' => $course->get('id'), 'name' => ucwords(strtolower($course->get('name'))), 'department_id' => $course->get('department_id'), 'number' => $course->get('number')));
} catch (Exception $e) {
}
}
$this->pageData['usersCourses'] = $usersCourses;
}
示例12: actionJsentity
/**
* js(on)entity returns an json object for the select2 widget
* @param string $search Text for the lookup
* @param integer of the set value
* @return json [description]
*/
public function actionJsentity($search = NULL, $id = NULL)
{
header('Content-type: application/json');
$clean['more'] = false;
$query = new Query();
if (!is_Null($search)) {
$mainQuery = $query->select('id, name AS text')->from('{{%entity}}')->where('UPPER(name) LIKE "%' . strtoupper($search) . '%"');
$command = $mainQuery->createCommand();
$rows = $command->queryAll();
$clean['results'] = array_values($rows);
} else {
if (!is_null($id)) {
$clean['results'] = ['id' => $id, 'text' => Entity::findOne($id)->name];
} else {
$clean['results'] = ['id' => 0, 'text' => 'None found'];
}
}
echo Json::encode($clean);
exit;
}
示例13: process
public function process($get, $post)
{
if (!isset($post['course_id']) || !is_numeric($post['course_id']) || !isset($_COOKIE['sessionId']) || !is_numeric($_COOKIE['sessionId'])) {
$this->failureReason = 'Sorry, there was an error.';
return false;
}
$query = new Query('action');
// Select all the courses that are in this user's session and have this course id
$result = $query->select('*', array(array('course_id', '=', $post['course_id']), array('session_id', '=', $_COOKIE['sessionId'])), '', 1);
if (count($result) != 0) {
// Abort because this course is already in the user's model
$this->failureReason = 'Sorry, there was an error';
return false;
}
// Now add this course to the user's model
$action = new Action();
$action->set('course_id', $post['course_id']);
$action->set('session_id', $_COOKIE['sessionId']);
$action->save();
return true;
}
示例14: process
public function process($get, $post)
{
// Select all of the courses that this user is already added
$query = new Query('action');
$result = $query->select('*', array(array('session_id', '=', $_COOKIE['sessionId'])));
$idsAlreadyAdded = array();
foreach ($result as $action) {
array_push($idsAlreadyAdded, $action->get('course_id'));
}
// Select all the courses where the query string is a sub-string of the name or id
$query = new Query('courses');
$result = $query->select('*', array(array('name', 'LIKE', '%' . $post['q'] . '%'), 'OR', array('number', 'LIKE', '%' . $post['q'] . '%')), array('number', 'ASC'), 100);
$courses = array();
foreach ($result as $course) {
if (!in_array($course->get('id'), $idsAlreadyAdded)) {
// Check that this course has not been added by the user yet
array_push($courses, array('id' => $course->get('id'), 'name' => ucwords(strtolower($course->get('name'))), 'department_id' => $course->get('department_id'), 'number' => $course->get('number'), 'description' => strlen($course->get('description')) == 0 ? 'No description' : $course->get('description')));
}
}
$this->pageData['courseResults'] = $courses;
return true;
}
示例15: getAreas
/**
* 获取子市区的键值对列表
* @param int/null $pid 父ID
* @param int $grade 等级
* @return array
*/
public static function getAreas($pid = null, $grade = self::GRADE_PROVINCE)
{
$key = 'arealist_' . $grade . '_' . $pid;
$areas = Yii::app()->cache->get($key);
// dump($areas);
if ($areas === false) {
$query = new Query(Yii::app()->db);
$query->select('id,name');
$query->from('area');
if ($pid == null) {
$query->andWhere('parent_id is null');
} else {
$query->andWhere('parent_id=:pid', array(':pid' => $pid));
}
$areas = $query->queryAll();
if (!empty($areas)) {
$areas = A::map($areas, 'id', 'name');
}
Yii::app()->cache->set($key, $areas, 60 * 60 * 24);
}
// dump($areas);
return $areas;
}