I have one curious question, hoping that someone can recommend the right approach with ActiveRecord pattern, under Yii.
Often times in tutorial you have codes like so
$post=Post::model()->find($condition,$params);
$post=Post::model()->findByPk($postID,$condition,$params);
Is it different from the following?
$post=Post::model();
$result = $post->find($condition,$params);
$result = $post->findByPk($postID,$condition,$params);
I am most likely wrong, but I have this sense that you would use less memory by creating a single Post::model() object, instead of creating one every time you do a query. However, I also fear that would defeat the purpose of atomic transaction under ActiveRecord pattern. Which approach in the code snips is recommended? and why?
Thank you for reading!