How do you get values from models?
After loading a model I the开发者_如何学Go only way to get to the data seems to be very ugly.
$this->User->read(NULL, 49);
print $this->User->data['User']['email'];
Most frameworks have a much nicer way of accessing like
$User = new Model_User(49);
print $User->email;
Is there anyway to do this in CakePHP 1.2/3?
If you're looking for a more type safe way to do it, unfortunately not. All model access is based on array structures and is one of the very things that frustrated me about Cake.
The normal case is when you assign the result from this->read to a variable i.e.:
$user = $this->User->read(NULL, 49);
print $user['User']['email'];
精彩评论