NYCPHP Meetup

NYPHP.org

[nycphp-talk] Inserting duplicate SQL primary keys

Cliff Hirsch cliff at pinestream.com
Wed Jul 25 16:00:11 EDT 2007


Apologies if this should be in the MySQL list, but it does seem to be a
PHP-level issue.

While testing, I just did a page refresh, which caused this action to be
repeated:

$query_string = "INSERT INTO task_category (task_id, category_id) VALUES
($taskId, $categoryId)";
$this->dbManager->DbQuery($query_string);

Obviously, on the page refresh, it threw an error (DB Error: already
exists), since it was already inserted.

The question:

Where should I be checking for this? Should I just suppress the error with
@$this->dbManager->DbQuery($query_string);? Should I just do a select
before-hand to see if the join is already in the table? Other ideas?

Cliff



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


More information about the talk mailing list