Example #1
0
 /**
  * Adds the FROM part to a query.
  *
  * @param  bool    $useAlias  Whether or not to alias the table
  * @param  string  $query
  */
 private function compileFrom($useAlias = true)
 {
     if (!$this->from) {
         throw new UnexpectedValueException('Cannot compile FROM clause because there are no tables ' . 'to compile. Did you forget to call from()?');
     }
     $parts = [];
     foreach ($this->from as $source => $alias) {
         // Allow no aliasing as well, as denoted by an it key
         if (!is_int($source)) {
             $parts[] = $useAlias ? e\alias($source, $alias) : $source;
         } else {
             $parts[] = $alias;
         }
     }
     return implode($parts, ', ');
 }
Example #2
0
 /**
  * Compiles the columns to select in a SELECT.
  *
  * @return  string
  */
 private function compileColumns()
 {
     if (!$this->select) {
         $this->select = ['*'];
     }
     $parts = [];
     foreach ($this->select as $column => $alias) {
         // Allow no aliasing as well, as denoted by an it key
         if (is_int($column)) {
             $parts[] = e\columnize($alias, $this->alias);
         } else {
             $column = e\columnize($column, $this->alias);
             $parts[] = e\alias($column, $alias);
         }
     }
     return implode($parts, ', ');
 }