Im trying to execute something like this
$SQL = "INSERT into cb_sent_alerts(user_id,message)
Select id, ' :message ' from story1";
$stmt->bindValue(':message', $_POST['message']);
But that just sends :message to the database, not the values of $_POST['message']; What can i do?
EDIT: very sorry should have specified, :message is not a column in cb_sent_alerts, rather i want the message there as a string.
Though it's never mentioned in the doc explicitly, you can work with placeholders in SELECT
part of INSERT ... SELECT
query the same way as with any other type of query. So this:
INSERT INTO cb_sent_alerts(user_id,message)
SELECT id, :message FROM story1
... end up with the right value (a string) if bound up by bindValue(':message', $_POST('message')
call.
Note that placeholders cannot be used for the column and table names, so the thing you were afraid of is just not possible. )