B
B
Banny_Boom2015-07-17 13:43:15
PHP
Banny_Boom, 2015-07-17 13:43:15

PDO not working, where is the error, 42P08?

Prepare - "UPDATE public.users SET id=:id, surname=:surname WHERE surname=:surname"
Bind - array(":surname"=>"filipov", ":id"=>18) - tried without : first
Error:
SQLSTATE[42P08]: Ambiguous parameter: 7 ERROR: inconsistent types deduced for parameter $2 LINE 1: UPDATE public.users SET id=$1, surname=$2 WHERE surname=$2 ^ DETAIL: text versus character varying
Data type is correct. ..
But I can’t understand what the error is .. please help

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2015-07-17
@Banny_Boom

PostgreSQL cannot determine the type of the parameter because it is used twice, in SET and in WHERE. Force its type

UPDATE `public`.`users`
    SET `id` = :id, `surname` = :surname::varchar(20) 
    WHERE `surname` = :surname::varchar(20)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question