Reply to Re: How to stop PEAR DB reporting errors?

Your name:

Reply:


Posted by Jim Moseby on 07/01/05 23:44

>
> I have a very simple script that has to either INSERT a record if one
> doesn't exist or UPDATE one if it does (the table has a unique index
> on 2 fields). So, i am using PEAR DB and i was hoping to do an INSERT,
> then trap any resulting error and if it creates an error (assume it is
> caused by a duplicate) and do the UPDATE.
>
> My problem is, i always get an error ("DB Error: already exists"),
> even if i preceed the $db->query() with @ ... or i switch
> error_reporting(0). It never allows me to do my own error handling.
>
> How should i be doing this? Am i on the right track? :-s

I know absolutely nothing about PEAR, but it seems to me that you would want
to use REPLACE.

<pseudocode>
"REPLACE into tablename (column1, column2...) values (value1, value2...)"
</pseudocode>

REPLACE will create a new record if one does not exist, and will replace an
existing record if it does.

JM

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация