Depending on the database you are working with (mysql, postgres) you
could read the documentation and look for a function that returns the
last ID
I think it's SELECT LAST_INSERT_ID();

On 10 feb, 18:00, Salam Fall <[EMAIL PROTECTED]> wrote:
> Just solved the problem
> Here is how I have done it
>                          $ret = $this->Client->query("Select id from clients 
> order by id
> DESC LIMIT 1");
>                          $newid=$ret[0]['clients']['id'] + 1;
>                          $yr=date("y");
>                          $account="$branch-$yr-00$newid";
>                         $this->data['Client']['acct_numb'] = $account;
>                         $this->Client->create();
>                         if ($this->Client->save($this->data)) etc....
>
> Now my other question is how do i create my own classes and make them
> available in the controller and the view??
>
> On Feb 9, 5:34 pm, Salam Fall <[EMAIL PROTECTED]> wrote:
>
> > Here is what i have done so far but it's not working
> >                           $branch="SEN";
>
> >                         $ret = $this->Client->findBySQL("Select id from 
> > clients order by id
> > DESC LIMIT 1");
> >                         $lastId=$ret[0]['id'];
> >                          $act=$lastId + 1;
> >                         $yr=date("y");
> >                          $account="$branch-$yr-00$act";
> >                           $this->data['Client']['acct_numb'] =
> > $account;
> >                         $this->Client->create();
> >                         if ($this->Client->save($this->data) etc....
>
> > On Feb 9, 5:31 pm, Salam Fall <[EMAIL PROTECTED]> wrote:
>
> > > Nubee here
>
> > > How do I find the last record in the database and have it's ID value
> > > in the controller and be able to manipulate it mathematically.
>
> > > Because all i want to do is put the ID of the last record of the
> > > Clients table add 1 to it and append the result to a string that will
> > > be used to create the Client account number.
>
> > > Also if I want to create my own custom functions or classes to add to
> > > my cake APP how do I do that.
>
> > > Thanks for your help.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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