示例#1
0
 public function __call($method, $arguments)
 {
     //Magic call below method in Db\Sql\Select
     $allowMagicCalls = array('where', 'from', 'columns', 'join', 'group', 'having', 'order', 'limit', 'offset');
     if (true === in_array($method, $allowMagicCalls)) {
         if (!$this->isInitialized) {
             $this->initialize();
         }
         if (!$this->isInitialized) {
             throw new Exception\NotInitializedException(sprintf('Sql must initialized before methed %s called', __METHOD__, $method));
         }
         $select = $this->getSelect();
         call_user_func_array(array($select, $method), $arguments);
         //Cache select options here
         $this->selectOptions[$method] = isset($arguments[0]) ? $arguments[0] : null;
         //Where maybe have multi columns
         if ($method == 'where') {
             $this->selectOptions['where'] = $select->where;
         }
         //Note: ZF2 will clear last select when use $this->sql->select();
         $this->select = $select;
         return $this;
     } else {
         return parent::__call($method, $arguments);
     }
 }