简体   繁体   中英

atk4 database table id

i've a question about atk4 MVCgrid, my db table doesn't have a field called "id" my primary key is id_material, i don't be able to change idfield, my SQL contain a file id that doesnt' exist so it fail. How i can change default id primary key field (id) with my real primary key?

My simple code:

class Model_Material  extends Model_Table 
{
    public $entity_code='material';
    public $table_alias='p';
    function defineFields(){
        parent::defineFields();
        $this->addField('id_material');
        $this->addField('material');
    }
}

Thank's

All you need to do is to create an alias:

$this->getField('id')->calculated(true);

function calculate_id(){
    return 'id_material';
}

You would have more difficulties with foreign keys. You might want to keep watch on 4.2 release, which will have more flexibility.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM