Yii Framework Forum: How to get comment id from post view shop.php - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How to get comment id from post view shop.php Rate Topic: -----

#1 User is offline   Equ 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 57
  • Joined: 27-November 09
  • Location:Russia, Moscow

Posted 10 December 2009 - 03:57 PM

I'm trying to get a comment id (suppose there is only one comment to that certain post) from post view shop.php (demo blog). I tried this

<?php print $model->comments->id; ?>


but unfortunately it didn't work. The relations are set in post model

'comments'=>array(self::HAS_MANY, 'Comment', 'postId'),


Any suggestions how to get this data?

Thank you.
0

#2 User is offline   tri 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,651
  • Joined: 20-November 08
  • Location:Stockholm, Sweden

Posted 10 December 2009 - 04:13 PM

View PostEqu, on 10 December 2009 - 03:57 PM, said:

I'm trying to get a comment id (suppose there is only one comment to that certain post) from post view shop.php (demo blog). I tried this

<?php print $model->comments->id; ?>


but unfortunately it didn't work. The relations are set in post model

'comments'=>array(self::HAS_MANY, 'Comment', 'postId'),


Any suggestions how to get this data?

Thank you.


'comments' will be an array
<?php print $model->comments[0]->id; ?>

/Tommy
Don't forget to read The Definitive Guide to Yii (en) (sv) | The class reference has the details
0

#3 User is offline   Equ 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 57
  • Joined: 27-November 09
  • Location:Russia, Moscow

Posted 10 December 2009 - 04:29 PM

Thanks a lot! :)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users