Example #1
0
 /**
  * @return Compiler
  */
 public function getCompiler() : Compiler
 {
     if ($this->compiler === null) {
         $this->compiler = $this->connection->getCompiler();
     }
     return $this->compiler;
 }
Example #2
0
 public function __construct(Connection $connection, Model $model)
 {
     $this->model = $model;
     $this->connection = $connection;
     $compiler = $connection->compiler();
     $query = new Select($compiler, $model->getTable());
     $whereCondition = new WhereCondition($this, $query);
     parent::__construct($compiler, $query, $whereCondition);
 }
Example #3
0
 /**
  * @param   array   &$columns   (optional)
  *
  * @return  \Opis\Database\ResultSet
  */
 protected function query(array &$columns = array())
 {
     $pk = $this->model->getPrimaryKey();
     if (!$this->query->isLocked() && !empty($columns)) {
         $columns[] = $pk;
     }
     return $this->connection->query((string) $this->query->select($columns), $this->query->getCompiler()->getParams());
 }
Example #4
0
 /**
  * @return  array
  */
 protected function &getResults()
 {
     if ($this->results === null) {
         $model = $this->modelClass;
         $this->model = new $model();
         $results = $this->connection->query((string) $this->query, $this->params)->fetchClass($this->modelClass, array($this->readonly, $this->connection))->all();
         $this->prepareResults($this->model, $results);
         $this->results =& $results;
     }
     return $this->results;
 }
Example #5
0
 /**
  * Delete records
  * 
  * @param   string|array    $tables (optional)
  * 
  * @return  int
  */
 public function delete($tables = array())
 {
     parent::delete($tables);
     $compiler = $this->connection->getCompiler();
     return $this->connection->count($compiler->delete($this->sql), $compiler->getParams());
 }
Example #6
0
 /**
  * @param   array   $columns
  * 
  * @return  int
  */
 public function set(array $columns)
 {
     parent::set($columns);
     $compiler = $this->connection->getCompiler();
     return $this->connection->count($compiler->update($this->sql), $compiler->getParams());
 }
Example #7
0
 /**
  * @param   string  $table
  * 
  * @return  boolean
  */
 public function into(string $table)
 {
     parent::into($table);
     $compiler = $this->connection->getCompiler();
     return $this->connection->command($compiler->insert($this->sql), $compiler->getParams());
 }
Example #8
0
 /**
  * Delete records
  * 
  * @param   string|array    $tables (optional)
  * 
  * @return  int
  */
 public function delete($tables = array())
 {
     parent::delete($tables);
     return $this->connection->count((string) $this, $this->compiler->getParams());
 }
Example #9
0
 /**
  * @param   array   $columns
  * 
  * @return  int
  */
 public function set(array $columns)
 {
     parent::set($columns);
     return $this->connection->count((string) $this, $this->compiler->getParams());
 }
Example #10
0
 public function __construct(Connection $connection, array $values)
 {
     parent::__construct($connection->compiler());
     $this->connection = $connection;
     $this->insert($values);
 }
Example #11
0
 public function __construct(Connection $connection, $tables)
 {
     parent::__construct($connection->compiler());
     $this->tables = $tables;
     $this->connection = $connection;
 }
Example #12
0
 /**
  * @return  mixed
  */
 protected function execute()
 {
     return $this->connection->column((string) $this->query, $this->compiler->getParams());
 }
Example #13
0
 /**
  * @param   string  $table
  * 
  * @return  boolean
  */
 public function into($table)
 {
     parent::into($table);
     return $this->connection->command((string) $this, $this->compiler->getParams());
 }