• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP QueryBuilder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


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


示例17: fillUsersGps

 public function fillUsersGps($userId, $leafId)
 {
     $qb = new QueryBuilder();
     $qb->delete(Tbl::get('TBL_USERS_GPS'))->where($qb->expr()->equal(new Field('user_id'), $userId));
     $this->query->exec($qb->getSQL());
     $gpsTree = $this->getNodeTree($leafId);
     foreach ($gpsTree as $treeNode) {
         $qb = new QueryBuilder();
         $qb->insert(Tbl::get('TBL_USERS_GPS'))->values(array('user_id' => $userId, 'node_id' => $treeNode["node_id"]));
         $this->query->exec($qb->getSQL());
     }
 }
开发者ID:Welvin,项目名称:stingle,代码行数:12,代码来源:UsersGps.class.php


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


示例19: newBaseQueryBuilder

 protected function newBaseQueryBuilder()
 {
     /**
      * override this
      */
     $conn = $this->getConnection();
     $grammar = $conn->getQueryGrammar();
     $oQB = new QueryBuilder($conn, $grammar, $conn->getPostProcessor());
     $oQB->setModel($this);
     return $oQB;
     //return parent::newBaseQueryBuilder(); // TODO: Change the autogenerated stub
 }
开发者ID:srit83,项目名称:laravel-extardent,代码行数:12,代码来源:Extardent.php


示例20: setControllerTemplateByHost

 public static function setControllerTemplateByHost(Host $host, $controller, $template)
 {
     $sql = MySqlDbManager::getQueryObject();
     $qb = new QueryBuilder();
     if (!empty($controller) or !empty($template)) {
         $qb->insert(Tbl::get('TBL_HOST_CONTROLLER_TEMPLATE'))->values(array('host_id' => $host->id, 'controller' => $controller, 'template' => $template))->onDuplicateKeyUpdate()->set(new Field('controller'), $controller)->set(new Field('template'), $template);
     } else {
         $qb->delete(Tbl::get('TBL_HOST_CONTROLLER_TEMPLATE'))->where($qb->expr()->equal(new Field('host_id'), $host->id));
     }
     $sql->exec($qb->getSQL());
     return $sql->affected();
 }
开发者ID:Welvin,项目名称:stingle,代码行数:12,代码来源:HostControllerTemplate.class.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP QueryExecutor类代码示例发布时间:2022-05-23
下一篇:
PHP Query类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap