In PHP, I use PDO with pgSQL drivers. I wanted to know how to get the value of the βRETURNβ clause given in the INSERT SQL query. My current code is as follows:
$query = 'INSERT INTO "TEST" (firstname, lastname) VALUES ('John', 'Doe') RETURNING user_id'; $queryHandle = $connection->prepare($query); $queryHandle->execute();
Obviously
$ queryHandle-> Execute ();
returns TRUE or FALSE. But I wanted to get the value "user_id" if the insert was successful. Can you guys give me a pointer on how to do this? Thanks.
php insert pdo postgresql
Chantz
source share