2

I am using PostgreSQL with PHP, and i want to use Upsert with Medoo,

Right now i am using query() function like this:

$data = $database->query("MY UPSERT QUERY")->fetchAll();

I want to create a function in Medoo for Upsert, Any idea for it?

HarisH Sharma
  • 1,101
  • 1
  • 11
  • 38
  • What are you fetching from `UPSERT` query? I mean you can if you use `RETURNING`, but generally those don't return anything. `query()` in this framework accepts `RAW SQL`, what did you try and didn't work? – Łukasz Kamiński Mar 31 '17 at 10:52
  • I want that if a record was inserted/updated in database then its id/primary key will be return. In case of insert it is newly inserted id. And in update case it is existing id. – HarisH Sharma Mar 31 '17 at 18:55
  • You don't know how upserts work in PostgreSQL or you are asking for something else? Upserts are done by `INSERT [..] ON CONFLICT [..]` Clause. – Łukasz Kamiński Apr 03 '17 at 06:19

0 Answers0