Reputation: 17340
in my database i have many fields into table and i want to need only 3 fields of that. for fetch data from that i have this method:
$siteSettings = array();
$siteSettings['site_copyright'] = SystemSetting::find('site_copyright')->value;
$siteSettings['site_generator'] = SystemSetting::find('site_generator')->value;
$siteSettings['site_date'] = SystemSetting::find('site_date')->value;
print_r( $siteSettings );
this method is correct and do not have a problem. but whats Easier than this?
Upvotes: 0
Views: 213
Reputation: 189
Have you tried using this method?
$siteSettings = SystemSetting::get(array('site_copyright', 'site_generator','site_date'));
print_r( $siteSettings );
or
$fields = array(
'site_copyright',
'site_generator',
'site_date'
);
$siteSettings = SystemSetting::get($fields);
Upvotes: 1