Re: Help with Model:find()

2008-08-21 Thread lauren
On Aug 21, 7:05 am, "Jon Bennett" <[EMAIL PROTECTED]> wrote: > Hi lauren, > > > I overrode the find() method in my Purchase model similar to what Nate > > Abele suggests inhttp://c7y.phparch.com/c/entry/1/art,mvc_and_cake > > woops - knew I should have read that link :p :) > > However, I think t

Re: Help with Model:find()

2008-08-21 Thread Jon Bennett
Hi lauren, > I overrode the find() method in my Purchase model similar to what Nate > Abele suggests in http://c7y.phparch.com/c/entry/1/art,mvc_and_cake woops - knew I should have read that link :p > However, I think the Containable Behavior is what I need. yes, it's overkill in your situatio

Re: Help with Model:find()

2008-08-20 Thread lauren
On Aug 20, 6:14 pm, "Jon Bennett" <[EMAIL PROTECTED]> wrote: > there's no 'magic' method called 'unpaid', there's only: Yes, I know. :) I overrode the find() method in my Purchase model similar to what Nate Abele suggests in http://c7y.phparch.com/c/entry/1/art,mvc_and_cake public function find

Re: Help with Model:find()

2008-08-20 Thread Jon Bennett
Hi Lauren, I meant 'Purchase' not Payment! $this->Account->Behaviors->attach('Containable'); $account = $this->Account->find('first', array( 'conditions'=>array('Account.id' => $account_id), 'contain'=>array( 'Purchase'=>array('conditions'=>array(

Re: Help with Model:find()

2008-08-20 Thread Jon Bennett
Hi lauren, > Before I finally discovered that there were replies to my > question :)I did end up going with a similar solution in order to > avoid "hackiness". > > Which actually brings me to another question: > > Should the following work?: > > Account has many Purchase > Purchase belongs to

Re: Help with Model:find()

2008-08-20 Thread lauren
On Aug 18, 8:43 am, "Jon Bennett" <[EMAIL PROTECTED]> wrote: > ... > a far easier solution to the problem would be to store an interger for > the status, you could assign things like so: > > 0 - unpaid/unprocessed > 1 - paid/processed > 2 - dispatched > 3 - refunded > Before I finally discovered

Re: Help with Model:find()

2008-08-18 Thread Kalt
Of course your solution is better and this is what I do too. I just wanted to show Lauren how to do with her own setup. On 18 août, 14:43, "Jon Bennett" <[EMAIL PROTECTED]> wrote: > Hi Kalt, > > > @jon : the "unpaid" status should not be in the Payments but in the > > Purchases > > ahh, yes - she

Re: Help with Model:find()

2008-08-18 Thread Jon Bennett
Hi Kalt, > @jon : the "unpaid" status should not be in the Payments but in the > Purchases ahh, yes - she wants all Purchases that have no payments made - I was really just trying to illustrate how containable can be used instead of the old hasOne/belongsTo hack. a far easier solution to the pr

Re: Help with Model:find()

2008-08-18 Thread Kalt
@jon : the "unpaid" status should not be in the Payments but in the Purchases On 18 août, 14:03, "Jon Bennett" <[EMAIL PROTECTED]> wrote: > Hi Lauren, > > providing you're using 1.2, a less hacky way would be to use the > Containable behaviour. > > $this->Purchase->Behaviors->attach('Containable'

Re: Help with Model:find()

2008-08-18 Thread Jon Bennett
Hi Lauren, providing you're using 1.2, a less hacky way would be to use the Containable behaviour. $this->Purchase->Behaviors->attach('Containable'); $results = $this->Purchase->find('all', array( 'conditions'=>array('Purchase.account_id' => $account_id, 'Payment.id' => null), '

Re: Help with Model:find()

2008-08-18 Thread Kalt
For now, you defined the following relations : - Account hasMany Purchase, Payment - Purchase hasMany Payment Right ? Now, try this : // controllers/purchases_controller.php function purchases_not_paid($account_id = null) { // We trick the bindings $this->Purchase->unbindModel(array('hasMan