NYCPHP Meetup

NYPHP.org

[nycphp-talk] Insert updating instead of inserting

Bruce Martin bmartin at mac.com
Fri Sep 30 18:13:16 EDT 2011


Hi all,

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. 

Just some background I have a table that contains:
id | user_id | item_id | description | debit | price | created | modified

id is the primary key 

a user should have multiple records, each time this is run it adds a new record to the table and the id, price, created and modified should change, item_id could change too.

I thought maybe mysql was getting confused, so I created a stored procedure to do this insert, but it still, on occasion updates.

Anyway has anyone experienced an issue where mysql will update instead of insert?

Thanks for any leads you might have at resolving this issue. 
Bruce Martin
The Martin Solution
Bruce at martinsolution.com
http://www.martinsolution.com


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20110930/c174f6f5/attachment.html>


More information about the talk mailing list