setSource() public method

Set SQL source
public setSource ( string $source ) : self
$source string
return self
Ejemplo n.º 1
0
 /**
  * init
  *
  * @return self
  */
 public function init()
 {
     // Setup source
     $adapter = new SqlSource();
     $adapter->setSource('SELECT * FROM musician');
     $this->setAdapter($adapter);
     $this->setDefaultLimit(25);
     $this->setAllowOrders(['title', 'id', 'created', 'updated']);
     $this->setAllowFilters(['id', 'nickname', 'image', 'music_type', 'group', 'concert_date']);
     return $this;
 }
Ejemplo n.º 2
0
 /**
  * init
  *
  * @return self
  */
 public function init()
 {
     // Setup source
     $adapter = new SqlSource();
     $adapter->setSource('SELECT * FROM pages');
     $this->setAdapter($adapter);
     $this->setDefaultLimit(25);
     $this->setAllowOrders(['title', 'id', 'created', 'updated']);
     $this->setAllowFilters(['title', 'alias', 'description', 'content', 'id']);
     return $this;
 }
Ejemplo n.º 3
0
 /**
  * Init SqlSource
  * @return self
  */
 public function init()
 {
     // Array
     $adapter = new SqlSource();
     $adapter->setSource('SELECT * FROM test');
     $this->setAdapter($adapter);
     $this->setDefaultLimit(10);
     $this->setAllowOrders(['name', 'id', 'status']);
     $this->setAllowFilters(['status', 'id', 'email']);
     $this->setDefaultOrder('name', Grid::ORDER_DESC);
     return $this;
 }
Ejemplo n.º 4
0
 /**
  * SQL Source Exception
  * @expectedException \Bluz\Grid\GridException
  */
 public function testSqlSourceThrowsGridException()
 {
     $adapter = new SqlSource();
     $adapter->setSource(['wrong source type']);
 }