【发布时间】:2013-07-31 15:47:42
【问题描述】:
我有一些代码在我的本地机器(WAMP,PHP 5.4.3)上运行良好,但在生产服务器(CentOS,PHP 5.4.11)上却没有,我不明白为什么,有问题代码行是:
$sharedList = SharedList::with('itemList')
->where('unique_url', '=', $uniqueURL)
->first();
如果我删除 with() 急切加载,那么它运行没有问题,如果我不这样做(并且我不需要在我的本地机器上),那么我会得到这个:
Argument 2 passed to Illuminate\Database\Eloquent\Relations\BelongsTo::match()
must be an instance of Illuminate\Database\Eloquent\Collection, instance of
ItemList given, called in /home/mgc/public_html/test/vendor/laravel/framework
/src/Illuminate/Database/Eloquent/Builder.php on line 474 and defined
/home/site/public_html/test/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/BelongsTo.php
line 154: public function match(array $models, Collection $results, $relation)
来自 SharedList 模型的相关关系信息是:
class SharedList extends Ardent {
public function itemList()
{
return $this->belongsTo('ItemList', 'list_id');
}
不知道是不是大小写问题,在with()方法中我试过ItemList、itemlist和itemList。
这可能是一个 Ardent 问题,但我尝试将 extend Ardent 替换为 extend Eloquent 无济于事。
【问题讨论】:
标签: php laravel laravel-4 eloquent ardent