Update postgresql if the key exist with php -
this question has answer here:
- insert, on duplicate update in postgresql? 16 answers
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
Post a Comment