Just learned this trick today, so though I'd share on the chance someone else needs it. For some functionality getting pasted on to an existing app, I wanted to do a table insert, but only if a "mostly similar" record does not exist. (While there are probably "better" ways using multi-column unique keys and such, I didn't want to mess with the existing application database.) PostgreSQL does not support WHERE clauses in INSERT statements, but using it within a SELECT is, so...
// using PDO place-holders...
$sql = "
INSERT INTO my_schema.table_name (
col_1,
col_2,
col_3
)
SELECT
:val_1,
:val_2,
:val_3
WHERE NOT EXISTS (
SELECT col1
FROM my_schema.table_name
WHERE col_1 = :val_1
AND col_2 = :val_2
)";