Ben*_*Ben 9 php eager-loading laravel laravel-4 laravel-3
在Laravel 3中,可以在模型中执行以下操作(http://laravel.com/docs/database/eloquent#eager):
class Book extends Eloquent
{
public $includes = array('author'); // this line
public function author()
{
return $this->belongs_to('Author');
}
}
Run Code Online (Sandbox Code Playgroud)
如果经常加载相同的模型,这是有用的.
在Laravel 4中,添加"此行"似乎并没有引起急切的加载.它似乎也没有在文档中提及(http://four.laravel.com/docs/eloquent#eager-loading).
它被其他东西取代了还是这个功能简直消失了?
更新:
我看过模型的来源(很高兴阅读).下雪了:
/**
* The relations to eager load on every query.
*
* @var array
*/
protected $with = array();
Run Code Online (Sandbox Code Playgroud)
是否有任何方法可以建议将其添加(返回)到文档中(这似乎是一件容易被忽视的小事情)?
| 归档时间: |
|
| 查看次数: |
2109 次 |
| 最近记录: |