atk4.2.1
我有这样的模式:
class Model_Cargo extends Model_Table {
public $table='cargo';
function init(){
parent::init();
$this->hasOne('Alumno');
$this->hasOne('Plan');
$this->addField('fecha')->type('date');
$this->addField('fechaCreacion')->type('date');
$this->addField('fechaVencimiento')->type('date');
$this->addField('name');
$this->addField('monto')->type('money');
$this->addField('cancelado')->type('boolean')->defaultValue(false);
$this->hasMany('Abono');
$this->addExpression('abonos')->set($this->refSQL('Abono')->sum('monto'));
}
}
我wanto做一个数学运算+或 - 有两个字段:其实我是想substracr场“蒙托”与表达“abonos”我该怎么办呢?
可以说,这样的事情:
$this->addExpression('balance')->set('monto'-'abonos');
//this does not work
我也沃尔德喜欢addCondition其中这些领域都是平等的。我能做到这一点?
东西艾克:
$this->addCondition('monto','abonos');
//this does not work