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 <[email protected]> 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 [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