好的,这个问题源于Laravel 4.1.23安装.我正在尝试使用Eloquent update()方法在包含连接的查询上更新多个记录:
ChildSchoolYear::whereNull('exit_date')->
join('school_years', 'child_school_years.school_year_id','=','school_years.id')->
update(array('child_school_years.exit_date'=>'`school_years`.`end_date`',
'child_school_years.editor_id'=>$userId))
Run Code Online (Sandbox Code Playgroud)
Laravel正在为我上面提供的查询内容生成正确的SQL,但生成的完整SQL语句是
update `child_school_years`
inner join `school_years` on `child_school_years`.`school_year_id` = `school_years`.`id`
set `child_school_years`.`exit_date` = `school_years`.`end_date`,
`child_school_years`.`editor_id` = 2,
`updated_at` = 2014-08-15 02:00:33 where `exit_date` is null)
Run Code Online (Sandbox Code Playgroud)
这将起作用,除了updated_atchild_school_years和school_years表中都存在自动添加的字段,因此Laravel 添加字段会触发异常Integrity constraint violation: 1052 Column 'updated_at' in field list is ambiguous.
关于如何驯化updated_at作品的任何建议?我很乐意让这个领域更新,但是如果有必要的话,如果有必要可以消除它,我会活下去.
我在Laravel工作,我有兴趣检查包含with()语句的Eloquent查询生成的SQL语句.出于某种原因,我只得到主查询.例如,当我跑
class Child extends EloquentVersioned {
public function childRequests()
{
return $this->hasMany('ChildRequest');
}
}
$childQuery = Child::orderBy('last_name')->orderBy('first_name')->with( 'childRequests');
return $childQuery->toSql();
Run Code Online (Sandbox Code Playgroud)
我回来了:
select `children`.* from `children` order by `last_name` asc, `first_name` asc
Run Code Online (Sandbox Code Playgroud)
如何获取with('childRequests')查询的SQL?
看来我并不是唯一一个在Laravel的DB :: raw(),DB :: select(),DB :: statement()和DB :: unrepared()方法之间挣扎的人.似乎一个人几乎需要尝试使用所有4的给定SQL语句来识别哪个将起作用.任何人都可以澄清它们之间的关系,以及它们用于何种目的?
我已经非常确定地证明,我使用标准回归生成的残差lm()可以通过具有 6 个左右自由度的 t 分布进行合理建模。我想使用glm()该错误模型,但我没有看到 t 适合其中一个系列。关于glm()与 t 配合良好的替代方案,或者可以作为 t 的替代品(或超集)的家族,有什么建议吗?