【发布时间】:2012-07-20 17:49:48
【问题描述】:
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'));
}
}
我想用两个字段进行数学运算 + 或 -: 我实际上想用表达式 'abonos' 子字段 'monto' 我该怎么做?
让我们这样说:
$this->addExpression('balance')->set('monto'-'abonos');
//this does not work
我还想在这些字段相等的情况下添加条件...我可以这样做吗?
类似的东西:
$this->addCondition('monto','abonos');
//this does not work
【问题讨论】:
标签: php user-interface frameworks atk4