예제 #1
0
 public function __get($name)
 {
     if (in_array($name, $this->_model->getExprColumns())) {
         if (!array_key_exists($name, $this->_exprValues)) {
             $this->_exprValues[$name] = $this->_model->getExprValue($this, $name);
         }
         return $this->_exprValues[$name];
     }
     foreach ($this->_getSiblingRows() as $r) {
         if ($r->hasColumn($name)) {
             return $r->{$name};
         }
     }
     throw new Kwf_Exception("Invalid column '{$name}' for model '" . get_class($this->getModel()) . "'");
 }
예제 #2
0
 public function getExprValue($row, $name)
 {
     if ($name instanceof Kwf_Model_Select_Expr_Interface) {
         $expr = $name;
     } else {
         $expr = $this->_exprs[$name];
     }
     if ($expr instanceof Kwf_Model_Select_Expr_Sql) {
         $select = $this->select();
         $select->whereEquals($this->getPrimaryKey(), $row->{$this->getPrimaryKey()});
         $select->limit(1);
         $options = array('columns' => array($name));
         $dbSelect = $this->_createDbSelectWithColumns($select, $options);
         return $dbSelect->query()->fetchColumn();
     }
     return parent::getExprValue($row, $name);
 }