I'm having an issue with PDO Prepared statements, where if you need to use the same bind variable multiple times, the query won't validate.
Example:
$params = array (
':status' => $status,
':userid' => $_SESSION['userid']
);
$stmt = $pdo->prepare ('
INSERT INTO
tableName
( userId, status )
VALUES
( :userid, ":status" )
ON DUPLICATE KEY UPDATE
status = ":status"
');
if ( ! $stmt->execute ( $params ))
{
print_r( $stmt->errorInfo ());
}
EDIT: The values of the $params
are:
Array ( [:status] => PAID [:userid] => 111 )
EDIT 2:
I've noticed that instead of the original values, instead of userid, 0 is inserted, and instead of status an empty string is inserted.