Thank you all for your reponses - it works now! Just for future
reference i used Brian's last response to solve it, but they all
work.

Thank you all for your time, it is greatly appreciated!
Ste

On 23 Sep, 08:49, "Dr. Loboto" <drlob...@gmail.com> wrote:
> As every one said, do this:
>
> $pilid = $this->Pil->find(
>     'first', // tell cake that you want one record, first one
>     array(
>         'conditions' => array('Pil.user_id' => $user_id),
>         'fields' => array('Pil.pilid'),
>         'order' => array('Pil.pilid' => 'DESC') // provide order
> preferred way
>     )
> );
>
> On Sep 23, 4:50 am, Steppio <stepisgr...@hotmail.com> wrote:
>
> > Hi everybody, this ones been doing my head in for some time now, hope
> > you can help me out, im sure its very simple but i just cant get it
> > working. Firstly the table structure is like this:
>
> > CREATE TABLE pil (
> >         id int(11) unsigned NOT NULL auto_increment primary key,
> >         user_id int(11) unsigned not null,
> >         pilid int(11) unsigned NOT NULL,
> >         pcode varchar(255),
> >         quantity text not null,
> >         created DATETIME,
> >         modified DATETIME
> > )ENGINE=InnoDB DEFAULT CHARSET=latin1;
>
> > And this is inside my pils_controller.php:
>
> > function newpil() {
> >                 $user_id = $this->Session->read('User.id');
> >                 $pilid = $this->Pil->find(
> >                 array(
> >                 'conditions' => array('Pil.user_id' => $user_id),
> >                 'fields' => array('Pil.pilid'),
> >                 'order' => array('Pil.pilid DESC'),
> >                 ));
>
> >                 $pilid2 = ($pilid['Pil']['pilid'] + 1);
>
> > ...
>
> > }
>
> > What i want is for the above function to pick out the last pil
> > (product inquiry list) that the user set-up and to add a 1 to that.
>
> > Any ideas where im going wrong? Any help will be greatly appreciated.
>
> > Thank you
> > Ste
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to