【发布时间】:2014-05-16 14:42:19
【问题描述】:
我将字段和值存储在键值样式表中。我想随着时间的推移存储用户数据的修订。当我从他们的数据中选择时,我只想要每个键的最新值。
http://sqlfiddle.com/#!2/d7138
我目前正在急切加载,但是当我只想要每个键的最后一个值时,这会选择此数组中的所有键。
public function healthProfile()
{
return $this->hasMany('PortalUserMember', 'portal_user_id')
->whereIn('key', [
'health.profile.sex',
'health.profile.birthday_day',
'health.profile.birthday_month',
'health.profile.birthday_year',
'health.profile.height_ft',
'health.profile.height_in',
'health.profile.weight_lbs',
'health.profile.contact_street_1',
// Could be anything at any point.
'health.profile.mail_pharmacy_name',
'health.profile.mail_pharmacy_fax',
'health.profile.mail_pharmacy_phone'
]);
}
更新
我这样做是为了临时解决:
【问题讨论】:
标签: php mysql sql laravel eloquent