Pregunta

I have a many things to insert into database colums.

    $connect->prepare("INSERT INTO users (username, password, message, date, time, id) VALUES (:username, :password, :message, :date, :time, :id");

Instead of binding them all, I created a array:

    $IDs = array($username, $password, $message, $time, $date, $ID);

How do I take each variable from this array and bind it? I am completely lost with PDO.

¿Fue útil?

Solución

use:

$sth->execute(array(':username' => $username, ':password' => $password, $message, $time, $date, $ID))

and for others...

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top