I'm trying to use PHP PDO to insert values into a PostgreSQL database, but encounter the following error message:
SQLSTATE[22P02]: Invalid text representation: 7 ERROR: array value must start with "{" or dimension information
The field type is a PostgreSQL Array .
Here is my code (simplified):
try {
$sql='INSERT INTO table (fieldName, foo) VALUES (?, ?)';
$fieldName=array('1','2');
$data=array($fieldName, 'bar'); # fieldName is array type in PostgreSQL
$STH = $conn->prepare($sql);
$STH->execute($data);
catch(PDOException $e) {
# Handle exception
}
Thanks!
$data=array(array('1','2'));
instead of$data=array('1','2');
? – George Cummins Jun 21 '13 at 21:38