ORM 关联查询设计
2019年1月6日 05:03
zodream框架
使用方法
$this->hasOne(class, 'local_key', 'foreign_key');
$this->hasOne(table, table_id, id);
$this->hasMany(class, 'local_key', 'foreign_key');
$this->hasMany(table, id, table_id);
流程
with('w')
with(['w' => function($query) { $query->select('a') }])
with('w:a')
    eagerLoad['w'] = function(){}
    eagerLoad['w'] = function($query) { $query->select('a') }
    eagerLoad['w'] = function($query) { $query->select('a') }
get()
    $model->w()
        $this->hasOne(table, table_id, id)
        $this->hasOne(table, table_id, id)->select('');
            Relation{table, local_key, foreign_key} : Query
    eagerLoad['w'](Relation)
    Relation(id[])->getResult()
    w => array