Re: No ID returning from the model when inserting new record

2009-05-15 Thread oly.yates

Yes I tried that and it didn't work had the same problem as if I did
$this->Document->id,
would return the id only on saving an existing document not on saving
a new Document
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: No ID returning from the model when inserting new record

2009-05-14 Thread oly.yates

Ok well the problem defiantly seems to be cake to getting the document
sequence as it all works fine when i do this:
if($this->Document->saveAll($this->data)){
if(!$this->Document->id){
$documentid = $this->Document->query("SELECT
documentid_seq.currval FROM dual");
$documentid = $documentid[0]['documentid_seq']
['currval'];
}else {
$documentid = $this->Document->id;
}
$message = '"Save Sucessful"';
$this->set(compact('message','documentid'));
$this->render('save', 'ajax');
}
}

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



Re: No ID returning from the model when inserting new record

2009-05-14 Thread oly.yates

Thx for the tip with "set".
Starting to suspect that the problem lies with my database and cake
not being able to get the current value of the sequence (I'm using
Oracle),
does cake rely on any naming conventions for sequences or indexes? I
get the following errors:

Notice (8): Undefined
 index:  documents [CORE\cake\libs\model\datasources\dbo
\dbo_oracle.php, line 862]

Warning (512):
 SQL Error: ORA-00936: missing expression [CORE\cake\libs\model
\datasources\dbo_source.php, line 525]
Query: SELECT .currval FROM dual

-SQL error -
SELECT .currval FROM dual   ORA-00936: missing expression




On 13 May, 22:53, Faza  wrote:
> It's a bit weird, especially that calling the same function to edit the
> record returns the proper id.
>
> i use the same property with such syntax:
>
> if ($this->Design->saveAll($this->data))
>             {  
>                 $this->notify(2,$this->Design->id);          
>                 $this->redirect('/designs',null,true);
>             }
>
> works like a charm.
>
> post results of
> debug($this->Document)
> placed inside the if().
>
> also a free tip:
> $this->set(compact('message', 'documentid')); will work with same effect
> as two separate set's.
>
> oly.ya...@googlemail.com pisze:
>
> > Hi I'm having an issue where when I insert a new document into the
> > database I'm not getting the id of the new record back. The save
> > function looks like this:
>
> > function save() {
> >         if($this->Document->save($this->data)){
> >             $documentid = $this->Document->id;
> >             $message = '"Save Sucessful"';
> >             $this->set(compact('message'));
> >             $this->set(compact('documentid'));
> >             $this->render('save', 'ajax');
> >         }
> >     }
> > I know the new record is saving to the database with an id as I can
> > see the new record in the database. I am also getting an id back when
> > I edit a document and save it using this function. I'm using the
> > latest version of cake (1.2.3.8166).
>
> > Any ideas where/what the problem is likely to be?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---