Пример #1
0
 /**
  * @param Select $select
  * @return string
  */
 public function _renderSelectColumns(Select $select)
 {
     $cols = $select->getForcedColumns() ? $select->getForcedColumns() : $select->getAllColumns();
     array_walk($cols, function (&$col) {
         if ($col instanceof Column) {
             $col = $this->_renderColumnWithAlias($col);
         } else {
             if ($col instanceof Token) {
                 $col = $this->_renderToken($col);
             }
         }
     });
     $prefix = " ";
     $separator = ", ";
     return $prefix . implode($separator, $cols);
 }
 public function testJoinColumns()
 {
     $select = new Select('project');
     $select->cols(['pid' => 'project_id']);
     $j = $select->join('user', 'user_id');
     $j->cols(['user_email' => 'email']);
     $c = $select->getAllColumns();
     $this->assertCount(2, $c);
     $this->assertEquals('pid', $c[0]->getAlias());
     $this->assertEquals('user_email', $c[1]->getAlias());
     $this->assertEquals('project_id', $c[0]->getName());
     $this->assertEquals('email', $c[1]->getName());
 }