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


PHP Query::from方法代码示例

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


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

示例1: getQuery

 public function getQuery()
 {
     $query = new Query(Yii::app()->db);
     $query->from('groupon as g');
     if ($this->id) {
         $query->andWhere('g.id=:id', array(':id' => $this->id));
     }
     if ($this->title) {
         $query->andWhere(array('like', 'g.title', '%' . $this->title . '%'));
     }
     if ($this->state) {
         $now = time();
         switch ($this->state) {
             case 'online':
                 //在线
                 $query->andWhere('g.begin_time<=:time and g.end_time>=:time', array(':time' => $now));
                 break;
             case 'offline':
                 //下线
                 $query->andWhere('g.end_time<:time', array(':time' => $now));
                 break;
             case 'beonline':
                 //即将上线
                 $query->andWhere('g.begin_time>:time', array(':time' => $now));
                 break;
             default:
                 break;
         }
     }
     return $query;
 }
开发者ID:yinhe,项目名称:yincart,代码行数:31,代码来源:SellGrouponSFM.php

示例2: 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;
 }
开发者ID:yinhe,项目名称:yincart,代码行数:18,代码来源:ARCates.php

示例3: 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;
 }
开发者ID:yinhe,项目名称:yincart,代码行数:13,代码来源:SellShopSFM.php

示例4: getQuery

 public function getQuery()
 {
     $query = new Query(Yii::app()->db);
     $query->from('groupon_biz');
     $query->andWhere('display=' . ARBiz::DISPLAY);
     if ($this->id) {
         $query->andWhere('id=:id', array(':id' => trim($this->id)));
     }
     if ($this->title) {
         $query->andWhere(array('like', 'title', '%' . $this->title . '%'));
     }
     if ($this->status) {
         $query->andWhere('examine_status=:status', array(':status' => $this->status));
     }
     $query->order('id desc');
     return $query;
 }
开发者ID:yinhe,项目名称:yincart,代码行数:17,代码来源:SellBizSFM.php

示例5: test

 public function test()
 {
     /*
     *  $query=new Query();
          $query->addSelect(['g.*'])
         ->from ([Order::tableName().' o'])
         ->leftJoin(Position::tableName().' p','o.id = p.id_order')
         ->leftJoin(Good::tableName(). ' g','p.id_good = g.id')
         ->where(['o.id'=>':id'],[':id'=>$id]);
     
          return $query->all();
     *
     */
     $query = new Query();
     $query->from('list');
     return $query->all();
 }
开发者ID:pumi11,项目名称:aau,代码行数:17,代码来源:MyList.php

示例6: 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;
 }
开发者ID:jackycgq,项目名称:advanced,代码行数:29,代码来源:ARArea.php

示例7: from

 /**
  * Parse from statement
  *
  * @param Query  $query
  * @param string $inputString
  *
  * @return string
  */
 private function from(Query $query, $inputString)
 {
     if (substr($inputString, 0, 1) == '(') {
         $fromString = $this->getWord($inputString, ')');
         $inputString = $this->trimString($inputString, $fromString . ')');
         $fromString = str_replace(array('(', ')'), '', $fromString);
         $query->from(explode(', ', $fromString));
     } else {
         $from = $this->getWord($inputString);
         $inputString = $this->trimString($inputString, $from);
         $query->from($from);
     }
     return $inputString;
 }
开发者ID:xamin123,项目名称:platform,代码行数:22,代码来源:Parser.php

示例8: from

function from($table)
{
    $query = new Query();
    return $query->from($table);
}
开发者ID:kidaa30,项目名称:Swevers,代码行数:5,代码来源:database.php

示例9: __construct

 /**
  * Constructor.
  *
  * Provide a Query object to run this query and return found objects.
  * Provide an integer to look for this ID (or $column).
  * Provide an array to create an new object filled with these values.
  *
  * @param mixed $mixed  What to get?
  * @param mixed $column Column to search in.
  *
  * @return void
  */
 public function __construct($mixed = null, $column = 'id')
 {
     //set modelname
     $this->modelName = get_called_class();
     //set table name
     if (empty($this->tableName)) {
         $this->tableName = Config::getSetting('db_table_prefix') . strtolower($this->modelName);
     }
     //cache fields
     parent::__construct();
     //determine action
     if ($mixed !== null) {
         if (is_object($mixed) && get_class($mixed) == 'Query' && Clockwork::isModuleLoaded('Data/Query')) {
             if ($column == 1) {
                 $this->values = $mixed->from(substr($this->tableName, strlen(Config::getSetting('db_table_prefix'))), null, true, true)->limit(1)->run(1);
                 if (empty($this->values)) {
                     $this->setError(404, 'Object not found');
                 }
             } else {
                 $this->objects = $this->createObjects($mixed->from(substr($this->tableName, strlen(Config::getSetting('db_table_prefix'))), null, true, true)->run());
             }
         } else {
             if (is_array($mixed)) {
                 foreach ($mixed as $key => $value) {
                     $this->set($key, $value);
                 }
             } else {
                 if (Clockwork::isModuleLoaded('Data/Query')) {
                     $query = new Query();
                     $this->values = $query->from(strtolower($this->modelName))->where($column . " = '" . $mixed . "'")->run(1);
                     if (empty($this->values)) {
                         $this->setError(404, 'Object not found');
                     }
                 }
             }
         }
     }
 }
开发者ID:JCquence,项目名称:Clockwork,代码行数:50,代码来源:Model.php

示例10: queryBuilder

 public static function queryBuilder()
 {
     $query = new Query();
     //        $user = new Query();
     //        $userQuery = $user->select('id')->from('tbl_posts')->where(['title' => 'php'])->one();
     /**
      * group by statement
      */
     //       return $query->select(['title', 'name'])->from('tbl_job')
     //           ->join('inner join', 'tbl_category', 'tbl_job.category_id = tbl_category.id')
     //           ->where(['>', 'tbl_job.category_id', 6])->all();
     $category_id = [2, 3, 4];
     /**
      * like and order
      */
     //return $query->select(['title', 'category_id'])->from('tbl_job')
     //    ->where(['like','title', ['php', 'java']])->orderBy(['category_id' => SORT_DESC])
     //    ->all();
     return $query->from('tbl_job')->orderBy('id');
 }
开发者ID:sydorenkovd,项目名称:yiiadv,代码行数:20,代码来源:Posts.php

示例11: testDeleteStatement_AddTable

 public function testDeleteStatement_AddTable()
 {
     $query = new Query("DELETE FROM `test`");
     $query->from("abc", Query::APPEND);
     $this->assertEquals("DELETE FROM `test` , `abc`", (string) $query);
 }
开发者ID:jasny,项目名称:dbquery-mysql,代码行数:6,代码来源:QueryTest.php


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