JuJoGuAl
JuJoGuAl

Reputation: 119

Postgres Differences between pg_delete and "DELETE FROM ..."

PHP: pg_delete: http://php.net/manual/es/function.pg-delete.php

and use: "Delete From . . ."

What is the difference between both sequences? Which one is more efficient? Which one is less probable to get errors?

Upvotes: 0

Views: 533

Answers (1)

Ray O'Donnell
Ray O'Donnell

Reputation: 781

To be honest, I'm only guessing here as I've never used pg_delete(), but I'd say that it constructs a DELETE FROM... query behind the scenes and sends it to the server.

Given this, the difference between them is that with DELETE FROM... you are writing the SQL by hand, while with pg_query() you're using a PHP function that does it for you (albeit at the cost of less flexibility).

Which you use will depend on what framework you're using for your database queries, and what you're most comfortable doing.

Upvotes: 1

Related Questions