On Wed, Jun 3, 2009 at 5:32 AM, liaogz82 <liaog...@gmail.com> 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;
>

If you're using 'list', I think that should be:
$newId2 = Set::extract($newId,'Subscription.{0}.scp_id');

$newId = Set::extract(
        $this->Subscription->find(
                'list',
                array(
                        'fields'=>'Subscription.scp_id',
                        'order'=>'Subscription.scp_id desc',
                        'limit'=> 1
                )
        ),
        'Subscription.{0}.scp_id'
);

$this->data['Subscription']['scp_id'] = $newId+1;

--~--~---------~--~----~------------~-------~--~----~
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