NYCPHP Meetup

NYPHP.org

[nycphp-talk] Insert updating instead of inserting

Federico Ulfo rainelemental at gmail.com
Fri Sep 30 19:13:11 EDT 2011


Weird issue, are you using INSERT INTO ... ON DUPLICATE KEY ... UPDATE?
http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html

Also if you don't want to receive any MySql error from the INSERT query you
might want to user INSERT IGNORE, it won't do nothing if the row you're
inserting is already there.

Just in case you don't find a simple solution, you can create a pipeline for
the chron job and let him handle all the insert queries.



On Fri, Sep 30, 2011 at 7:00 PM, Dan Cech <dcech at phpwerx.net> wrote:

> Bruce,
>
>
>  I have an issue I hope someone can help me figure out. We have a Mysql
>> database
>> two php processes that insert new records into a table. There should never
>> be a
>> time when these processes update a record they should only insert a new
>> one.
>> These processes run simultaneously one running from a cron job and the
>> other
>> running when requested is made via an ajax call.
>>
>> For some reason when each process is working at the same time It seems to
>> not
>> insert a new record but update a similar record. I am explicitly calling
>> insert
>> and I do not include the primary_key id in the insert statement.
>>
>
> Can you post the output from SHOW CREATE TABLE and an example of the
> queries you're running?
>
> Also, please don't create a new topic by hitting reply and changing the
> subject, it breaks threading in most mail clients.
>
> Dan
> ______________________________**_________________
> New York PHP Users Group Community Talk Mailing List
> http://lists.nyphp.org/**mailman/listinfo/talk<http://lists.nyphp.org/mailman/listinfo/talk>
>
> http://www.nyphp.org/Show-**Participation<http://www.nyphp.org/Show-Participation>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20110930/2902cc63/attachment.html>


More information about the talk mailing list