Is it possible to submit data with PDO and having the class variables private instead of public?
I’d like to be able to use prepare and execute, in execute it’s just array($classObject), but it has to have public variables. Is there a way to use private variables and still use prepare and execute?
Example:
$query = $this->handle->prepare("INSERT INTO `$table` ($fields) VALUES ($values)");
$query->execute(array($data));
You are looking to bind data to parameters in the query:
In the example I’ve used a single variable, but the example can be simple expanded to arrays, just by imploding them: