ORM 关联查询设计

Fork Me On Github
zodream zodream框架 2019年01月

使用方法

php
       

$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);
1234567

流程

php
                  
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
123456789101112131415161718
点击查看全文
0 274 0