Your model looks wrong. My guess is that Cake can't find it and is therefore 
creating it's own version on the fly that doesn't therefore have the primaryKey 
definition. Make sure your file is called /app/models/amg_predio.php and the 
content is (note the lack of 's'):

<?php
        class AmgPredio extends AppModel {
                var $name = 'AmgPredio';
                var $primaryKey = 'gid';
        }
?>

Jeremy Burns
Class Outfit

jeremybu...@classoutfit.com
http://www.classoutfit.com

On 9 Jun 2011, at 15:34, MrMariscal wrote:

> I have a model definition where I override the primaryKey as follows:
> 
> 
> <?php
>       class Amg_Predios extends AppModel {
>               var $name = 'Amg_Predios';
>               var $primaryKey = 'gid';
>       }
> ?>
> 
> but when in my controller I use the:
> 
> 
>       $this->AmgPredio->save( $this->data );
> 
> I get this error:
>       Notice (8): Undefined index: id [CORE/cake/libs/model/model.php, line 
> 1329]
> 
> And after it, a message who says I'm trying to insert a duplicate record,
> because the primarykey already exists.
> 
> I have flushed the cache and it is still not working.
> 
> Any clues about what I'm doing wrong?
> 
> Thanks in advance.
> 
> --
> View this message in context: 
> http://cakephp.1045679.n5.nabble.com/Override-primarikey-Undefined-index-id-Error-tp4472931p4472931.html
> Sent from the CakePHP mailing list archive at Nabble.com.
> 
> -- 
> Our newest site for the community: CakePHP Video Tutorials 
> http://tv.cakephp.org 
> Check out the new CakePHP Questions site http://ask.cakephp.org and help 
> others with their CakePHP related questions.
> 
> 
> 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

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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

Reply via email to