Calculated field always returns 1 - atk 4.2

感情迁移 提交于 2019-12-23 03:52:30

问题


I have a model that has a calculated field. The value returned is always 1. After turning the debug on, 1 is hardcoded in the query:

<?php class Model_Income extends Model_base_Income {
    function init(){
        parent::init();
        $this->debug();
        $this->addField('year')->calculated(true);
    }
    function calculate_year(){
        return '22';
    }
}

Query returned by debug

    select `name`
,(select `name` from `client` where `income`.`client_id` = `client`.`id` )
`client`,`amount`,`date`,`comment`,1 `year`,`id` 
    from `income`

I am using atk 4.2


回答1:


in 4.2 do so:

in model.

$this->add("Field_Expression", "year")->set("22");

or any sql query instead of 22.



来源:https://stackoverflow.com/questions/10286262/calculated-field-always-returns-1-atk-4-2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!