object-relational mapping: what's best proceed exercise getters?


what should occur i $user->get_email_address()?



option 1: lift email castle database demand



public duty get_email_address() {
(!$this->email_address) {
$this->read_from_database('email_address');
}
relapse $this->email_address;
}


option 2: lift email castle (and user attributes) database vigilant creation



public duty __construct(..., $id = 0) {
($id) {
$this->load_all_data_from_db($id);
}
}

public duty get_email_address() {
relapse $this->email_address;
}


my simple doubt presumably it's best minimize array database queries, presumably it's best minimize volume information gets distant database.



another luck it's best bucket attributes you'll need many / enclose slightest information during vigilant origination all else demand.



a follow-up question: orm condensation frameworks activerecord do?



Comments

Popular posts from this blog

list macos calm editors formula editors

how hibernate @any-related annotations?

why does floated <input> control floated component slip over too distant right ie7, nonetheless firefox?