Update postgresql if the key exist with php -


this question has answer here:

im converting php app work postgresql instead of mysql.

before had function using pdo:

$stmt = $db->prepare("insert $table(id,name,info) values(:id,:name,:info) on duplicate key update name=:name,info=:info"); $stmt->execute(array(':id' => $id, ':name' => $name, :info' => $info)); 

if key not exist creates new entry, or else updates entry.

how possible same postgresql?

i have read articles, no 1 clear on have do. need write trigger or rule this?

or write check in php if entry/id exist, , determine if should update or create new?

im using postgres 9.1.8

http://en.wikipedia.org/wiki/upsert

you can run merge command trought prepare execute it.

i guess should work


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -