开发者

In Propel, can I select fields to return after save()

开发者 https://www.devze.com 2023-02-08 17:28 出处:网络
I create a new comment object and save it $comment = new Comment(); $comment->setText(\'this is a comment\');

I create a new comment object and save it

$comment = new Comment();
$comment->setText('this is a comment');
$comment->setIp($ip);
$开发者_开发问答comment->save();

When I do a var_dump($comment), I see that the object has a lot of detail that I don't want to pass to the view in MVC architecture. This means that I have to do extra filtering in the view.

So is there a way, right after save() to select only the fields that I will later want to pass to the view? Something like this code, so that the $comment object now has only the text field

$comment->save();
$comment->select(array('text'));


I'd just pass the object... But if you want to have the columns in array you can either use toArray() or getByName() methods.

Having only some columns in an ORM object doesn't make sense to me.

You have your question tagged as both Doctrine and Propel - this answer is for Propel.

0

精彩评论

暂无评论...
验证码 换一张
取 消