Inheritance: extends AbstractBuilder, use trait Bluz\Db\Query\Traits\From, use trait Bluz\Db\Query\Traits\Where, use trait Bluz\Db\Query\Traits\Order, use trait Bluz\Db\Query\Traits\Limit
示例#1
0
 public function advancedSelect()
 {
     $self = static::getInstance();
     $select = new Query\Select();
     $select->select('d.id , d.title, d.description, d.cost, c.name AS category')->from('dishes', 'd')->join('d', 'categories', 'c', 'd.categoryId = c.id')->setFetchType($self->rowClass);
     return $select;
 }
示例#2
0
 /**
  * Init SelectSource
  * @return self
  */
 public function init()
 {
     // Array
     $adapter = new SelectSource();
     $select = new Select();
     $select->select('*')->from('test', 't');
     $adapter->setSource($select);
     $this->setAdapter($adapter);
     $this->setDefaultLimit(10);
     $this->setAllowOrders(['name', 'id', 'status']);
     $this->setAllowFilters(['status', 'id', 'email']);
     return $this;
 }
示例#3
0
文件: Grid.php 项目: dezvell/skeleton
 /**
  * init
  *
  * @return self
  */
 public function init()
 {
     // Create Select
     $select = new Select();
     $select->select('u.*, GROUP_CONCAT( ar.`name` SEPARATOR ", " ) AS rolesList')->from('users', 'u')->leftJoin('u', 'acl_users_roles', 'aur', 'u.`id` = aur.`userId`')->leftJoin('aur', 'acl_roles', 'ar', 'ar.`id` = aur.`roleId`')->groupBy('u.id');
     // Setup adapter
     $adapter = new SelectSource();
     $adapter->setSource($select);
     $this->setAdapter($adapter);
     $this->setDefaultLimit(25);
     $this->setAllowOrders(['login', 'email', 'status', 'id']);
     $this->setAllowFilters(['login', 'email', 'status', 'id', 'roleId']);
     return $this;
 }
示例#4
0
文件: Db.php 项目: 9618211/framework
 /**
  * Create new query select builder
  * @api
  * @param string $select The selection expressions
  * @return Query\Select
  */
 public function select(...$select)
 {
     $query = new Query\Select();
     $query->select(...$select);
     return $query;
 }
示例#5
0
 /**
  * Prepare Db\Query\Select for current table:
  *  - predefine "select" section as "*" from current table
  *  - predefine "from" section as current table name and first letter as alias
  *  - predefine fetch type
  *
  * <code>
  *     // use default select "*"
  *     $select = Users\Table::select();
  *     $arrUsers = $select->where('u.id = ?', $id)
  *         ->execute();
  *
  *     // setup custom select "u.id, u.login"
  *     $select = Users\Table::select();
  *     $arrUsers = $select->select('u.id, u.login')
  *         ->where('u.id = ?', $id)
  *         ->execute();
  * </code>
  *
  * @return Query\Select
  */
 public static function select()
 {
     $self = static::getInstance();
     $select = new Query\Select();
     $select->select($self->table . '.*')->from($self->table, $self->table)->setFetchType($self->rowClass);
     return $select;
 }