Exemplo n.º 1
0
Arquivo: Delete.php Projeto: kwn/quark
 /**
  * Compile the SQL query and return it.
  *
  * @return  string
  */
 public function compile()
 {
     $query = 'DELETE FROM ' . $this->quoter->quoteTable($this->table);
     if (!empty($this->where)) {
         $query .= ' WHERE ' . $this->compileConditions($this->where);
     }
     if (!empty($this->orderBy)) {
         $query .= ' ' . $this->compileOrderBy($this->orderBy);
     }
     if (null !== $this->limit) {
         $query .= ' LIMIT ' . $this->limit;
     }
     $this->sql = $query;
     return parent::compile();
 }
Exemplo n.º 2
0
Arquivo: Select.php Projeto: kwn/quark
 /**
  * Compile the SQL query and return it.
  *
  * @return  string
  */
 public function compile()
 {
     $quote_column = array($this->quoter, 'quoteColumn');
     $quote_table = array($this->quoter, 'quoteTable');
     $query = 'SELECT ';
     if (true === $this->distinct) {
         $query .= 'DISTINCT ';
     }
     if (empty($this->select)) {
         $query .= '*';
     } else {
         $query .= implode(', ', array_unique(array_map($quote_column, $this->select)));
     }
     if (!empty($this->from)) {
         $query .= ' FROM ' . implode(', ', array_unique(array_map($quote_table, $this->from)));
     }
     if (!empty($this->join)) {
         $query .= ' ' . $this->compileJoin($this->join);
     }
     if (!empty($this->where)) {
         $query .= ' WHERE ' . $this->compileConditions($this->where);
     }
     if (!empty($this->groupBy)) {
         $query .= ' ' . $this->compileGroupBy($this->groupBy);
     }
     if (!empty($this->having)) {
         $query .= ' HAVING ' . $this->compileConditions($this->having);
     }
     if (!empty($this->orderBy)) {
         $query .= ' ' . $this->compileOrderBy($this->orderBy);
     }
     if ($this->limit !== null) {
         $query .= ' LIMIT ' . $this->limit;
     }
     if ($this->offset !== null) {
         $query .= ' OFFSET ' . $this->offset;
     }
     if (!empty($this->union)) {
         $query = '(' . $query . ')';
         foreach ($this->union as $u) {
             $query .= ' UNION ';
             if ($u['all'] === true) {
                 $query .= 'ALL ';
             }
             $query .= '(' . $u['select']->compile() . ')';
         }
     }
     $this->sql = $query;
     return parent::compile();
 }
Exemplo n.º 3
0
Arquivo: Update.php Projeto: kwn/quark
 /**
  * Compile the SQL query and return it.
  *
  * @return  string
  */
 public function compile()
 {
     $query = 'UPDATE ' . $this->quoter->quoteTable($this->table);
     $query .= ' SET ' . $this->compileSet($this->set);
     if (!empty($this->where)) {
         $query .= ' WHERE ' . $this->compileConditions($this->where);
     }
     if (!empty($this->orderBy)) {
         $query .= ' ' . $this->compileOrderBy($this->orderBy);
     }
     if ($this->limit !== null) {
         $query .= ' LIMIT ' . $this->limit;
     }
     $this->sql = $query;
     return parent::compile();
 }