If your Profile Model has already been defined $recursive = 1 or
greater, then you can do in Controller:
$this->Profile->unbindModel(array('hasMany' =>array('user_image')))
before
$this->Profile->findAll()
This makes your Profile gets main_image, but no user_image. Keep in
mind the unbindModel affects only the VERY NEXT findAll(). Look at
following codes, results differ for 2 immediate calls of findAll();
$this->Profile->unbindModel(array('hasMany'
=>array('user_image')));
$firstResult = $this->Profile->findAll(); //without user_image
$secondResult = $this->Profile->findAll(); //with user_image again.
jinhr
On 2月14日, 下午5时21分, "mallyone" <[EMAIL PROTECTED]> wrote:
> I'm trying to figure out how to return a list of users with only one
> user_image, the one with 'main'=1 in the user_images table.
>
> I also need to be able to return user.*, and it's associated images
> for another action.
>
> How should I handle this? Should I make another model called
> profile_single_image or something that would
> handle this kind of query? Can I ask it to ignore the user_image part
> of the model when using findAll? What's the best practices way?
>
> Thanks in advance...
>
> P.S. here's my model
> <?php
> class Profile extends AppModel
> {
> var $name = 'Profile';
> var $useTable = 'Users';
> var $hasOne = array('main_image' =>
> array('className' => 'UserImage',
> 'conditions' => 'main=1',
> 'order' => '',
> 'limit' => '1',
> 'exclusive' => false,
> 'finderQuery' => ''
> )
> );
> var $hasMany = array('user_image' =>
> array('className' => 'UserImage',
> 'conditions' => '',
> 'order' => '',
> 'limit' => '',
> 'exclusive' => false,
> 'finderQuery' => ''
> )
> );
>
> }
>
> ?>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---