Thursday, March 4, 2010

Re: Using REPLACE INTO with MySQL

@Zaky: although this might not be a SQL standard, it is a part of
MySQL, and is useful functionality to use. This is why I am trying to
find out whether anyoen else has overcome this problem.

Additionally, my web host does not allow me access to create stored
procedures, so the stored procedure is unfortunately not an option.

@genellern: using $Model->saveField() doesn't really help me too much
either. Some of the tables that I am needing to use in this project
that I am looking into this for have multiple primary keys. As such,
it would involve far fewer queries to do a REPLACE INTO as opposed to
searching for the entry based on conditions, and updating it using the
discovered primary key.

@C Gábor: the whole point of this is to *not* use $Model->query() :P

On Mar 4, 12:42 pm, Zaky Katalan-Ezra <procsh...@gmail.com> wrote:
> Why do you want to use this, out of  sql standard, statement in the first
> place
> According to the documentation the operation performed when there is a match
> id/index is DELETE then INSERT and not UPDATE.
> If you have on delete  FK constraint  or any auto increment columns you are
> going to face some issues.
>
> I  advice you not to use it at all.
> Use a stored procedure instead then you can bypass the REPLACE limitation of
> having a PK   or unique index.
> This way you also use one transaction to the database.

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: