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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php