Oh yes by the way, the above codes generate this error: Column 'scp_id' cannot be null
Means there is no value in $newId2 On Jun 3, 5:32 pm, liaogz82 <[email protected]> wrote: > Hi all, > > I need help in cakePHP. > > I am using this framework in my area of work. I have successfully > migrated from the old database that uses an auto increment field as > the primary key to one that uses uuid as the primary key. > unfortunately the users request the old ID to be remain in place so > that they can identify, as UUID is too long and unreadable. > > I am trying my very best to figure out how to do the implementation of > the auto increment in cakePHP, that is to use the codes below: > > $newId = $this->Subscription->find('list', > array( > 'fields'=>'Subscription.scp_id', > 'order'=>'Subscription.scp_id desc', > 'limit'=> 1 > ) > ); > $newId2 = Set::extract($newId,'{0}.Subscription.scp_id'); > $this->data['Subscription']['scp_id'] = $newId2+1; > > the idea is to extract the latest rolling number in scp_id field and > then add 1 to it to become the new identifyable id for the system > users, unfortunately the system keeps giving errors. is there a way > out? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
