You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What do you think about using switch (not if) in read function? More readable, more fast (if you need to use a lot of api/params). Less chance to make error when adding other "if". What do you think?
function read($model, $queryData = array()) {
switch ($queryData['fields']) {
case 'people' : if (!empty($queryData['conditions']['username'])) {
$url = 'flickr.people.findByUsername&' . $this->_buildParams(array(
'username',
), $queryData, true);}
break;
case 'photos' : if (!empty($queryData['conditions']['photoset_id'])) {
$url = 'flickr.photosets.getPhotos&' . $this->_buildParams(array(
'photoset_id',
), $queryData, true);}
break;
case 'sizes' : if (!empty($queryData['conditions']['photo_id'])) {
$url = 'flickr.photos.getSizes&' . $this->_buildParams(array(
'photo_id',
), $queryData, true);}
break;
case 'sets' : if (!empty($queryData['conditions']['user_id'])) {
$url = 'flickr.photosets.getList&' . $this->_buildParams(array(
'photo_id',
), $queryData, true);}
break;
default:
}
return $this->_request($url);
}
The text was updated successfully, but these errors were encountered:
I'm testing a rewrite on the last push that actually completely optimizes the code even further. I have thought of using a switch, and with the fields comparison part at the very least it's not ruled out.
Unfortunately I haven't taken the time to look at the write actions (Insert, Update, Delete) yet to determine if this new approach will work for them too.
I highly recommend taking a glance at the new code and if you wish you can fill out the (plenty) missing api methods I haven't bothered to get to yet in the config file
Hi!
What do you think about using switch (not if) in read function? More readable, more fast (if you need to use a lot of api/params). Less chance to make error when adding other "if". What do you think?
The text was updated successfully, but these errors were encountered: