Yii Framework Forum: How can i user a scope in the with()? - Yii Framework Forum

Jump to content

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

How can i user a scope in the with()? Rate Topic: -----

#1 User is offline   holala 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 74
  • Joined: 23-December 09

Posted 06 February 2010 - 01:56 AM

i definded a scope in User model,just like :
public function sID($id)
{
...
}


and in controller group,i want use this scope in with()
Groups::model()->with('User');

but i don't know how to call the sID function in the model User.

Please help!

Thank you!
0

#2 User is offline   Onman 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 175
  • Joined: 26-December 09
  • Location:The Netherlands

Posted 06 February 2010 - 04:31 AM

Try
$result=Groups::model()->sID($id)->with('User')->findAll();

0

#3 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,017
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 06 February 2010 - 07:41 AM

@holala:
You can't use parameterized scopes in with(), only those defined in scopes(). See the section at the bottom of this page:
http://www.yiiframew...de/database.arr
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