PDO and PGSQL: ERROR: syntax error at or near "SET"

From: Date: Mon, 07 Aug 2006 11:48:58 +0000
Subject: PDO and PGSQL: ERROR: syntax error at or near "SET"
Groups: php.general 
Request: Send a blank email to php-general+get-240233@lists.php.net to get a copy of this message
Hi all! I'm trying to learn using PDO and PostgreSQL together a little bit and I have some problems with (I thinks, auto incrementing fields) I have the following sample DB: CREATE TABLE users ( uid SERIAL UNIQUE NOT NULL, login TEXT NOT NULL, password TEXT NOT NULL, PRIMARY KEY (uid) ); and the following PHP code: <?php try { $db = new PDO('pgsql:host=localhost;dbname=testing', 'XXXX', 'ZZZZZ'); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $query = "INSERT INTO users SET uid = :uid, login = :login, password = :password"; $stmt = $db->prepare($query); $uid = ""; $login = "erik"; $password = "erikSecretPass"; $stmt->bindParam(':uid', $uid); $stmt->bindParam(':login', $login); $stmt->bindParam(':password', $password); $stmt->execute(); $db = null; } catch (PDOException $e) { print "Error!: " . $e->getMessage() . "<br/>"; die(); } ?> When running the script I get the following error message: Error!: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "SET" at character 19 I know that I doing something bad, maybe with the udi column, how to use auto incrementing columns with PDO? Thanks very much for your time. Erik Gyepes

« previous php.general (#240233) next »