当前位置: 首页>>代码示例>>PHP>>正文


PHP QueryBuilder::select方法代码示例

本文整理汇总了PHP中QueryBuilder::select方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryBuilder::select方法的具体用法?PHP QueryBuilder::select怎么用?PHP QueryBuilder::select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QueryBuilder的用法示例。


在下文中一共展示了QueryBuilder::select方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct(Registry $doctrineRegistry)
 {
     $this->doctrineRegistry = $doctrineRegistry;
     $this->qbOroUsers = $this->doctrineRegistry->getManager()->getRepository('OroUserBundle:User')->createQueryBuilder('u');
     $this->qbOroUsers->select('u');
     $this->qbDiamanteUsers = $this->doctrineRegistry->getManager()->getRepository('DiamanteUserBundle:DiamanteUser')->createQueryBuilder('u');
     $this->qbDiamanteUsers->select('u');
 }
开发者ID:jalopezsuarez,项目名称:diamantedesk-application,代码行数:8,代码来源:CombinedUsersDatasource.php

示例2: getDBCurrentDateTime

/**
 * Get Mysql's current datetime by selecting NOW()
 * 
 * @return string
 */
function getDBCurrentDateTime($isTimestamp = false)
{
    $sql = MySqlDbManager::getQueryObject();
    $qb = new QueryBuilder();
    if ($isTimestamp) {
        $qb->select(new Func("UNIX_TIMESTAMP", new Func("NOW"), 'now'));
    } else {
        $qb->select(new Func("NOW", null, 'now'));
    }
    return $sql->exec($qb->getSQL())->fetchField('now');
}
开发者ID:Welvin,项目名称:stingle,代码行数:16,代码来源:helpers.inc.php

示例3: queryString

 protected static function queryString($lang_id = null, $host_id = null, $module = null, $page = null, $cacheMinutes = null)
 {
     $qb = new QueryBuilder();
     $qb->select(new Field('title'), new Field('meta_keywords'), new Field('meta_description'))->from(Tbl::get('TBL_PAGE_INFO'));
     if ($lang_id === null) {
         $qb->andWhere($qb->expr()->isNull(new Field('lang_id')));
     } else {
         $qb->andWhere($qb->expr()->equal(new Field('lang_id'), $lang_id));
     }
     if ($host_id === null) {
         $qb->andWhere($qb->expr()->isNull(new Field('host_id')));
     } else {
         $qb->andWhere($qb->expr()->equal(new Field('host_id'), $host_id));
     }
     if ($module === null) {
         $qb->andWhere($qb->expr()->isNull(new Field('module')));
     } else {
         $qb->andWhere($qb->expr()->equal(new Field('module'), $module));
     }
     if ($page === null) {
         $qb->andWhere($qb->expr()->isNull(new Field('page')));
     } else {
         $qb->andWhere($qb->expr()->equal(new Field('page'), $page));
     }
     return $qb->getSQL();
 }
开发者ID:Welvin,项目名称:stingle,代码行数:26,代码来源:PageInfo.class.php

示例4: checkCredentials

 /**
  * Check validity of username, password and other auth factors
  * 
  * @param string $username
  * @param string $password
  * @param array $additionalCredentials
  * @param boolean $writeCookie
  * @throws UserAuthFailedException
  * @return User
  */
 public function checkCredentials($username, $password, $additionalCredentials = array(), $writeCookie = false)
 {
     $qb = new QueryBuilder();
     $qb->select(new Field('id'), new Field('password'), new Field('salt'))->from(Tbl::get('TBL_USERS', 'UserManager'))->where($qb->expr()->equal(new Field('login'), $username));
     $this->query->exec($qb->getSQL());
     if ($this->query->countRecords() == 1) {
         $userData = $this->query->fetchRecord();
         $hashToCheck = static::getUserPasswordHash($password, $userData['salt']);
         if ($userData['password'] === $hashToCheck) {
             $usr = $this->doLogin($userData['id'], $additionalCredentials, $writeCookie);
             try {
                 $hookParams = array("user" => $usr, "additionalCredentials" => $additionalCredentials);
                 HookManager::callHook("UserAuthSuccess", $hookParams);
             } catch (UserAuthFailedException $e) {
                 $this->doLogout();
                 throw $e;
             }
             return $usr;
         }
     }
     // Failed login nothing returned from above code
     $hookParams = array("username" => $username, "password" => $password, "additionalCredentials" => $additionalCredentials);
     HookManager::callHook("UserAuthFail", $hookParams);
     throw new UserAuthFailedException("Incorrect login/password combination");
 }
开发者ID:Welvin,项目名称:stingle,代码行数:35,代码来源:UserAuthorization.class.php

示例5: initUserAnswers

 /**
  * Loads user's answers into private $this->profileAnsers field
  *
  */
 private function initUserAnswers($cacheMinutes = 0)
 {
     $qb = new QueryBuilder();
     $qb->select(new Field('profile_id'))->from(Tbl::get('TBL_PROFILE_SAVE'))->where($qb->expr()->equal(new Field('user_id'), $this->userId));
     $this->query->exec($qb->getSQL(), $cacheMinutes);
     $this->profileAnswers = $this->query->fetchFields("profile_id");
 }
开发者ID:Welvin,项目名称:stingle,代码行数:11,代码来源:UserProfile.class.php

示例6: getLastId

 public function getLastId()
 {
     $qb = new QueryBuilder();
     $qb->select($qb->expr()->max(new Field('id'), 'lastId'))->from(Tbl::get('TBL_CHAT_MESSAGES'));
     $lastId = $this->query->exec($qb->getSQL())->fetchField('lastId');
     return empty($lastId) ? 0 : $lastId;
 }
开发者ID:Welvin,项目名称:stingle,代码行数:7,代码来源:ChatMessageManager.class.php

示例7: getControllerTemplateByHost

 public static function getControllerTemplateByHost(Host $host)
 {
     $sql = MySqlDbManager::getQueryObject();
     $qb = new QueryBuilder();
     $qb->select(new Field('*'))->from(Tbl::get("TBL_HOST_CONTROLLER_TEMPLATE"))->where($qb->expr()->equal(new Field('host_id'), $host->id));
     $sql->exec($qb->getSQL());
     return $sql->fetchRecord();
 }
开发者ID:Welvin,项目名称:stingle,代码行数:8,代码来源:HostControllerTemplate.class.php

示例8: getEventsLastId

 public function getEventsLastId()
 {
     $qb = new QueryBuilder();
     $qb->select($qb->expr()->max(new Field('id'), 'maxId'))->from(Tbl::get('TBL_COMET_EVENTS'));
     $maxId = $this->query->exec($qb->getSQL())->fetchField('maxId');
     if (empty($maxId)) {
         $maxId = 0;
     }
     return $maxId;
 }
开发者ID:Welvin,项目名称:stingle,代码行数:10,代码来源:CometEvents.class.php

示例9: getGroupsList

 public function getGroupsList($cacheMinutes = null)
 {
     $qb = new QueryBuilder();
     $qb->select(new Field('*'))->from(Tbl::get('TBL_TEXTS_GROUPS'));
     $this->query->exec($qb->getSQL(), $cacheMinutes);
     $groups = array();
     foreach ($this->query->fetchRecords() as $data) {
         array_push($groups, $this->getGroupObjectFromData($data));
     }
     return $groups;
 }
开发者ID:Welvin,项目名称:stingle,代码行数:11,代码来源:TextsGroupManager.class.php

示例10: isValidCountryCode

 /**
  * Check if given country code is valid
  * 
  * @param string $countryCode
  * @param int $cacheMinutes
  */
 public function isValidCountryCode($countryCode = null, $cacheMinutes = null)
 {
     $qb = new QueryBuilder();
     $qb->select($qb->expr()->count("*", "count"))->from(Tbl::get('TBL_LOCATIONS'))->where($qb->expr(new Field('country'), $countryCode));
     $this->query->exec($qb->getSQL(), $cacheMinutes);
     $count = $this->query->fetchField('count');
     if ($count > 0) {
         return true;
     }
     return false;
 }
开发者ID:Welvin,项目名称:stingle,代码行数:17,代码来源:GeoIP.class.php

示例11: search

 public function search($array, $limit = 100)
 {
     $qb = new QueryBuilder();
     $q = $qb->select();
     foreach ($array as $key => $val) {
         $q->where($key, $val);
     }
     $query = $q->getQueryString();
     $rows = $limit == -1 ? 9999999 : (int) $limit;
     $select = Solr::select()->rows($rows)->search($query);
     return $this->solr_client->core($this->collection)->select($select);
 }
开发者ID:ProjectOrangeBox,项目名称:solr-model,代码行数:12,代码来源:Solr_model.php

示例12: __construct

 /**
  * Constructor
  * 
  * @param Librarian $librarian The librarian interface responsible for the query
  * @param DBAL\Connection $db A Doctrine Connection
  * @param int $limit The maximum number of results to return
  * @param array $orderBy An assoc. array of indexName => direction
  * @param array $indexes An assoc. array of indexName => Index
  */
 public function __construct(LibrarianInterface $librarian, DBAL\Connection $db, $limit, array $orderBy, array $indexes)
 {
     $this->librarian = $librarian;
     $this->indexes = $indexes;
     $this->db = $db;
     $this->limit = $limit;
     $this->queryBuilder = $this->db->createQueryBuilder();
     $this->queryBuilder->setMaxResults($limit);
     foreach ($this->indexes as $index) {
         $index->setQuery($this);
         $index->setQueryBuilder($this->queryBuilder);
     }
     // TODO: make this explicitly defined?
     $this->mainIndex = current($this->indexes);
     foreach (array_slice($this->indexes, 1) as $name => $index) {
         $this->queryBuilder->leftJoin($this->mainIndex->getName(), $index->getTableName(), $index->getName($quote = true), $this->mainIndex->getName() . '.id = ' . $this->db->quoteIdentifier($name) . '.id');
     }
     $this->queryBuilder->select('distinct ' . $this->mainIndex->getName() . '.id')->from($this->mainIndex->getTableName(), $this->mainIndex->getName($quote = true));
     foreach ($orderBy as $name => $direction) {
         $this->indexes[$name]->orderBy($direction);
     }
 }
开发者ID:taproot,项目名称:librarian,代码行数:31,代码来源:Query.php

示例13: parseLogForFloodingIps

 /**
  * Parse requests log and blacklist flooding IPs.
  * Should be called by cron job every minute.
  */
 public function parseLogForFloodingIps()
 {
     $tablesToLock = array(Tbl::get('TBL_SECURITY_REQUESTS_LOG'), Tbl::get('TBL_SECURITY_FLOODER_IPS'));
     MySqlDbManager::getDbObject()->startTransaction();
     $qb = new QueryBuilder();
     $qbSelect = new QueryBuilder();
     $qbSelect->select(new Field('ip'))->from(Tbl::get('TBL_SECURITY_REQUESTS_LOG'))->where($qbSelect->expr()->greaterEqual(new Field('count'), $this->config->requestsLimit));
     $qb->insertIgnore(Tbl::get('TBL_SECURITY_FLOODER_IPS'))->fields('ip')->values($qbSelect);
     $this->query->exec($qb->getSQL());
     $this->query->exec("TRUNCATE TABLE `" . Tbl::get('TBL_SECURITY_REQUESTS_LOG') . "`");
     if (!MySqlDbManager::getDbObject()->commit()) {
         MySqlDbManager::getDbObject()->rollBack();
     }
 }
开发者ID:Welvin,项目名称:stingle,代码行数:18,代码来源:RequestLimiter.class.php

示例14: getAliases

 public function getAliases(TextValue $textValue, $cacheMinutes = null)
 {
     if (!is_numeric($textValue->id)) {
         throw new InvalidArgumentException("TextValue ID have to be numeric");
     }
     $qb = new QueryBuilder();
     $qb->select(new Field('*'))->from(Tbl::get('TBL_TEXTS_ALIASES'))->where($qb->expr()->equal(new Field('value_id'), $textValue->id));
     $this->query->exec($qb->getSQL(), $cacheMinutes);
     $arrayToReturn = array();
     foreach ($this->query->fetchRecords() as $data) {
         array_push($arrayToReturn, $this->getTextAliasObjectFromData($data));
     }
     return $arrayToReturn;
 }
开发者ID:Welvin,项目名称:stingle,代码行数:14,代码来源:TextsAliasManager.class.php

示例15: findByPk

 /**
  * Initiates a find by PK query
  *
  * @param $pk
  * @param $select
  * @return QueryBuilder
  */
 public static function findByPk($pk, $select = null)
 {
     $instance = self::createInstance();
     $instance->getFields();
     if ($instance->primaryKey == null) {
         return null;
     }
     $query = new QueryBuilder($instance->getTable(), 'SELECT');
     if ($select != null) {
         $query->select($select);
     }
     $query->where([$instance->primaryKey => $pk]);
     return $query->one();
 }
开发者ID:jellingsen,项目名称:db-models,代码行数:21,代码来源:BaseModel.php


注:本文中的QueryBuilder::select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。