Re: Theory again - mysql_query(INSERT INTO table...
On Sep 29, 7:30 am, Conrad [EMAIL PROTECTED] wrote: I am not finding the logic in doing the equiv. of an INSERT query. I am not seeing how $this-Model-save($this-data) knows which it is, an insert or an update. Can anyone spell it out for me, Sometimes I think I am somewhat simple minded. where $data is what you pass to save: if (($this-Model-id === a pk that is in the database) OR ($data[ModelName][id] === a pk that is in the database)) { it's an update } else { it's an insert } hth, AD Conrad --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Theory again - mysql_query(INSERT INTO table...
In other words, if you don't pass a 'id', or pass 'id' = null, it will do an insert, otherwise if there is a non-null value for id it will update. ??? Conrad On Sep 29, 12:25 am, AD7six [EMAIL PROTECTED] wrote: On Sep 29, 7:30 am, Conrad [EMAIL PROTECTED] wrote: I am not finding the logic in doing the equiv. of an INSERT query. I am not seeing how $this-Model-save($this-data) knows which it is, an insert or an update. Can anyone spell it out for me, Sometimes I think I am somewhat simple minded. where $data is what you pass to save: if (($this-Model-id === a pk that is in the database) OR ($data[ModelName][id] === a pk that is in the database)) { it's an update } else { it's an insert } hth, AD Conrad --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Theory again - mysql_query(INSERT INTO table...
On Sep 29, 8:29 am, Conrad [EMAIL PROTECTED] wrote: In other words, if you don't pass a 'id', or pass 'id' = null, it will do an insert, otherwise if there is a non-null value for id it will update. ??? That isn't what I said. If it isn't clear try it. One thing to note depending on your cake version, the first parameter in the url may be taken to be the id of the primary model. AD --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Theory again - mysql_query(INSERT INTO table...
I am not finding the logic in doing the equiv. of an INSERT query. I am not seeing how $this-Model-save($this-data) knows which it is, an insert or an update. Can anyone spell it out for me, Sometimes I think I am somewhat simple minded. Conrad --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---