RajeshK RajeshK - 5 days ago 6
PHP Question

possible situation where we should use pg_send_query in place of pg_query

What are the best possible situations where we should use pg_send_query in place of pg_query

Many times we just need to fire a query and don't require the query result, which is one possible situation i think. Although query failed or succeed can be required at some point later.

Answer

From the PHP documentation:

pg_send_query() sends a query or queries asynchronously to the connection. Unlike pg_query(), it can send multiple queries at once to PostgreSQL and get the results one by one using pg_get_result().

If you wanted to send multiple queries at once then pg_send_query() might be useful for you. It would allow you to send multiple queries to Postgres in a single call.

Comments