【发布时间】:2013-03-27 05:51:02
【问题描述】:
在 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');
}
}
如果经常加载相同的模型,这很有用。
在 Laravel 4 中,添加“这一行”似乎不会导致急切加载。文档中似乎也没有提到它 (http://four.laravel.com/docs/eloquent#eager-loading)。
它是被其他东西取代还是这个功能完全消失了?
更新:
我查看了模型的源代码(很好读)。现在是:
/**
* The relations to eager load on every query.
*
* @var array
*/
protected $with = array();
我有什么方法可以建议将其添加(返回)到文档中(这似乎是那些很容易被忽视的小事之一)?
【问题讨论】:
标签: php laravel eager-loading laravel-4 laravel-3