You are here: Re: Database abstraction layers « PHP Programming Language « IT news, forums, messages
Re: Database abstraction layers

Posted by Toby Inkster on 11/19/32 11:47

Iván Sánchez Ortega wrote:
> Colin McKinnon wrote:
>
>> I want some code where I present an array of data, and the corresponding
>> primary key and let the code work out whether to INSERT or UPDATE it,[...]
> [...]
>> Anybody any suggestions?
>
> Use MySQL and REPLACE statements.

Very abstract.

One technique for the OP might be to prepare both an INSERT and an UPDATE
statement. Run the INSERT statement; if it fails then there's probably
already a row with that primary key, so run the UPDATE statement. Or you
could run UPDATE first, check the number of rows updated; if 0, run the
INSERT. Not particularly clean, but should be quite portable.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

 

Navigation:

[Reply to this 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

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