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


PHP QueryBuilder类代码示例

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


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

示例1: 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

示例2: 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

示例3: getEntities

 protected function getEntities($key)
 {
     if (!isset($this->relationships[$key])) {
         return false;
     }
     $relationship = $this->relationships[$key];
     if (!isset($this->managers[$relationship['manager']])) {
         $this->managers[$relationship['manager']] = $this->factory->get($key);
     }
     $manager = $this->managers[$relationship['manager']];
     /* @var $manager ManagerAbstract */
     $query = new QueryBuilder($manager->table(), $this->factory::connection(), $relationship['conditions']);
     $original_params = $query->params();
     $params = array();
     foreach ($original_params as $param) {
         if (stripos($param, 'entity.' === 0)) {
             $param = $this->entity[substr($param, 7)];
         }
         $params[] = $param;
     }
     if ($relationship['relation'] == 'HasOne') {
         $this->entities[$key] = $manager->fetch($query, $params);
     } else {
         $this->entities[$key] = $manager->fetchAll($query, $params);
     }
     return $this->entities[$key];
 }
开发者ID:thoom,项目名称:dbm,代码行数:27,代码来源:RelationshipManager.php

示例4: scopeIdOrUuid

 /**
  * Method for searching model by Id or Uuid
  * @param  QueryBuilder $query
  * @param  Int|Uuid $value
  * @return Illuminate\Database\Eloquent\Builder
  */
 public function scopeIdOrUuid($query, $value)
 {
     if (!Uuid::isValid($value) && !is_numeric($value)) {
         throw (new ModelNotFoundException())->setModel(get_class($this));
     }
     return $query->where($this->primaryKey, '=', $value)->orWhere('uuid', '=', $value);
 }
开发者ID:beautycoding,项目名称:modelutils,代码行数:13,代码来源:UuidModel.php

示例5: playerQuery

 private function playerQuery(\QueryBuilder $query, Request $request)
 {
     if ($team = $request->query->get('team')) {
         $query->where('team')->is($team);
     }
     return $query->getArray(array('name', 'outdated'));
 }
开发者ID:allejo,项目名称:bzion,代码行数:7,代码来源:SearchController.php

示例6: load

 function load($sh, $c_query = null)
 {
     $db = DB::Instance();
     $qb = new QueryBuilder($db, $this->_doname);
     if ($sh instanceof SearchHandler) {
         if ($this->_templateobject->isAccessControlled()) {
             if (isModuleAdmin()) {
                 $cc = new ConstraintChain();
                 $cc->add(new Constraint('usercompanyid', '=', EGS_COMPANY_ID));
                 $cc->add(new Constraint('id', '=', EGS_COMPANY_ID), 'OR');
                 $sh->addConstraintChain($cc);
                 $qb->setDistinct();
             } else {
                 $cc = new ConstraintChain();
                 $cc->add(new Constraint('usernameaccess', '=', EGS_USERNAME));
                 $cc->add(new Constraint('owner', '=', EGS_USERNAME), 'OR');
                 $cc2 = new ConstraintChain();
                 $cc2->add(new Constraint('usercompanyid', '=', EGS_COMPANY_ID));
                 $sh->addConstraintChain($cc);
                 $sh->addConstraintChain($cc2);
                 $qb->setDistinct();
             }
         }
         $this->sh = $sh;
     }
     $this->_load($sh, $qb, $c_query);
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:27,代码来源:PersonCollection.php

示例7: query

 public function query($table = null)
 {
     if ($table === null) {
         $table = $this->_table;
     }
     $req = new QueryBuilder($this->_class);
     return $req->_from($table);
 }
开发者ID:JuniorBoaventura,项目名称:orm,代码行数:8,代码来源:Table.php

示例8: testClauses

 public function testClauses()
 {
     $arguments = array();
     $arguments[] = 'all';
     $arguments[] = array('condition' => 'state=?', 'columns' => 'name', 'order by' => 'last_login asc');
     $query = new QueryBuilder('author', $arguments);
     $this->assertEqual('select name from authors where state=? order by last_login asc', $query->compile()->getQueryString());
 }
开发者ID:BackupTheBerlios,项目名称:medick-svn,代码行数:8,代码来源:QueryBuilderTest.php

示例9: __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

示例10: __construct

 public function __construct()
 {
     $this->bs = new DisciplineBS(null);
     $qbuilder = new QueryBuilder('discipline');
     $qbuilder->addOrder("dsc_name", QueryBuilder::$ASC);
     $qbuilder->addOrder("dsc_code", QueryBuilder::$ASC);
     $this->disciplines = $this->bs->findNotDeleted($qbuilder);
 }
开发者ID:renatorroliveira,项目名称:algod,代码行数:8,代码来源:DisciplineSelect.php

示例11: __construct

 /**
  * Constructor
  */
 public function __construct()
 {
     parent::__construct();
     $this->load->library('model/QueryBuilder');
     $this->load->library('Enviroment');
     $this->db = $this->getDb();
     $this->_query = new QueryBuilder($this->db, false);
     $this->_query->setTable($this->_tabla);
 }
开发者ID:CarlosAyala,项目名称:midas-codeigniter-modulo-emergencias,代码行数:12,代码来源:MY_Model.php

示例12: logCustom

 public static function logCustom($name, $value)
 {
     $remoteIP = "";
     if (isset($_SERVER['REMOTE_ADDR'])) {
         $remoteIP = $_SERVER['REMOTE_ADDR'];
     }
     $qb = new QueryBuilder();
     $qb->insert(Tbl::get('TBL_MIXED_LOG'))->values(array("session_id" => session_id(), "name" => $name, "value" => $value, "ip" => $remoteIP));
     Reg::get('sql')->exec($qb->getSQL());
 }
开发者ID:Welvin,项目名称:stingle,代码行数:10,代码来源:DBLogger.class.php

示例13: addCatchAllWhereClause

 /**
  * @param QueryBuilder $q
  * @param              $filter
  * @return array
  */
 protected function addCatchAllWhereClause(&$q, $filter)
 {
     $unique = $this->generateRandomParameterName();
     //ensure that the string has a unique parameter identifier
     $string = $filter->strict ? $filter->string : "%{$filter->string}%";
     $expr = $q->expr()->orX($q->expr()->like('f.label', ':' . $unique), $q->expr()->like('f.alias', ':' . $unique));
     if ($filter->not) {
         $expr = $q->expr()->not($expr);
     }
     return array($expr, array("{$unique}" => $string));
 }
开发者ID:Yame-,项目名称:mautic,代码行数:16,代码来源:LeadFieldRepository.php

示例14: scopeArchiveFiltered

 /**
  * Get latest posts filtered by year and month?
  *
  * @param QueryBuilder $query
  * @param int $year
  * @param int $month
  */
 public function scopeArchiveFiltered($query, $year, $month)
 {
     return $query->where(function ($query) use($year, $month) {
         if ($year) {
             $query->where(DB::raw('YEAR(created_at)'), $year);
         }
         if ($month) {
             $query->where(DB::raw('MONTH(created_at)'), $month);
         }
     })->orderBy('posts.created_at', 'DESC');
 }
开发者ID:Erbenos,项目名称:laravel-blog,代码行数:18,代码来源:Post.php

示例15: 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


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