i want run a query in a insert statement in pdo when i bind my value with prepare and bindValue functions.
i want run a code like this in pdo:
INSERT INTO test_table1 (`item1`, `item2`, `item3`)
VALUES (
'value of item1',
'value of item2',
(SELECT `value_of_item3` FROM test_table2 WHERE `item_id` = '3' LIMIT 1)
)
in mysql and in pdo when i don't bind my value, it work very well but in pdo when i bind my value like bellow code it doesn't work.
$sth = $db->prepare("INSERT INTO MyGuests (`item1`, `item2`, `item3`)
VALUES (:item1, :item2, :item3)");
$sth->bindValue(':item1', 'value of item1');
$sth->bindValue(':item2', 'value of item2';
$sth->bindValue(':item3', '(SELECT `value_of_item3` FROM test_table2 WHERE `item_id` = '3' LIMIT 1)');
$sth->execute();
Someone have an idea what to do?