Esempio n. 1
0
 /**
  * Generate the query.
  *
  * @return  string
  */
 public function __toString()
 {
     $out = 'SELECT';
     if (null !== $this->_distinctOrAll) {
         $out .= ' ' . $this->_distinctOrAll;
     }
     if (!empty($this->_columns)) {
         $out .= ' ' . implode(', ', $this->enclose($this->_columns));
     } else {
         $out .= ' *';
     }
     if (!empty($this->_from)) {
         $out .= ' FROM ';
         $handle = [];
         foreach ($this->_from as $alias => $from) {
             if (is_int($alias)) {
                 $handle[] = $this->enclose($from);
             } else {
                 $handle[] = $this->enclose($from) . ' AS ' . $this->enclose($alias);
             }
         }
         $out .= implode(', ', $handle);
     }
     $out .= parent::__toString();
     if (!empty($this->_groupBy)) {
         $out .= ' GROUP BY ' . implode(', ', $this->enclose($this->_groupBy));
         if (!empty($this->_having)) {
             $out .= ' HAVING ' . $this->_having;
         }
     }
     return $out;
 }
Esempio n. 2
0
 /**
  * Generate the query.
  *
  * @return  string
  */
 public function __toString()
 {
     $out = 'UPDATE';
     if (null !== $this->_or) {
         $out .= ' OR ' . $this->_or;
     }
     $out .= ' ' . $this->enclose($this->_table);
     $set = [];
     foreach ($this->_set as $name => $value) {
         $set[] = $this->enclose($name) . ' = ' . $value;
     }
     $out .= ' SET ' . implode(', ', $set);
     return $out . parent::__toString();
 }
Esempio n. 3
0
 /**
  * Generate the query.
  *
  * @return  string
  */
 public function __toString()
 {
     return 'DELETE FROM ' . $this->enclose($this->_from) . parent::__toString();
 }