I'm trying to do the following query:

  $query = 'select Paper.* from papers as Paper
    left join volumes as Volume on (Paper.volume_id = Volume.id)
    left join users_volumes as UsersVolume on (UsersVolume.volume_id =
Volume.id)
    where UsersVolume.user_id = %d
    or Paper.user_id = %d';

I want to do the above query in cake, but I need to do it through
passing some conditions to $this->paginate(), because this is the way
I've set up my record level access framework.

My conditions would be:

                $options = array('OR' =>
                    array('UsersVolume.user_id' => $user_id),
                    array('Paper.user_id' => $user_id));

We're fine up until this point, but UsersVolume doesn't exist - so I
want to use Containable behavior to force a join on this column. My
paginate variable, where I'm trying to force the LEFT JOIN is:

    var $paginate = array(
        'fields' => array('id', 'volume_id', 'is_published',
'created', 'title', 'slug'),
        'order' => 'Volume.number DESC, Paper.id ASC',
        'contain' => array(
            'Volume' => array(
                'fields' => array('id', 'number'),
            )),
        );

Unfortunately no matter what I try here, I don't get a LEFT JOIN. My
relationships are:

  Paper belongsTo User
  Paper belongsTo Volume
  Volume hasAndBelongsToMany User

Does anyone have any ideas?

Thanks,
Aidan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to