0
我将字段和值存储在键值样式表中。我想随时保存用户数据的修订版。当我从他们的数据中选择时,我只想要每个键的最新值。选择最后一个有价值的记录
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'
]);
}
更新
我做这是一个临时解决办法:
有没有机会你知道Laravel的Eloquent版本? –
对不起,我不熟悉Laravel或Eloquent – FuzzyTree