hi,

its seems fine, but you might be able to save lot of lines by using
the 
http://bakery.cakephp.org/articles/view/an-improvement-to-unbindmodel-on-model-side
extension

Regards,
Ritesh

On Dec 3, 10:36 am, designvoid <[EMAIL PROTECTED]> wrote:
> Hi all!
>
> I'm in the process of building my first app with Cake and was
> wondering if someone could look over some code and let me know if what
> I have done is correct or waay off base...
>
> Its basically a few lines to get 3 different arrays populated with
> data from 2 tables via a HABTM releationship.
>
> It gets a bit complicated when I try and use conditions from each
> table, but hopefully to you guys it should make sense.. anyways, here
> it is:
>
>             //closed jobs
>          $this->Job->User->recursive = 3;
>          $this->Job->unbindModel(array('hasMany'=>array('Notes')));
>          
> $this->Job->User->unbindModel(array('hasAndBelongsToMany'=>array('Modules')));
>
>          $conditions = array("status_id" => 3);
>          $this->set('closed_jobs', $this->Job->findAll($conditions));
>
>             //user's open jobs
>         $this->Job->unbindModel(array('hasMany'=>array('Notes')));
>         $this->Job->bindModel(array('hasOne'=>array('JobUser'=>array())));
>         $constraint['Job.status_id'] = '<> 3';
>         $constraint['JobUser.user_id'] = $this->Session->read('User');
>         $this->set('user_jobs', $this->Job->findAll($constraint));
>
>             //other user's open jobs
>         $this->Job->unbindModel(array('hasMany'=>array('Notes')));
>         $this->Job->bindModel(array('hasOne'=>array('JobUser'=>array())));
>         $constraint['Job.status_id'] = '<> 3';
>         $constraint['JobUser.user_id'] = '<> '.$this->Session->read('User');
>
>         $this->set('others_jobs', $this->Job->findAll($constraint));
>
> If I'm doing things correctly then great!! If not, a pointer or 2
> would be gratefully recieved!
>
> TIA,
>
> d.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to