Hi there! I am used to using PDO to prepare my SQL queries in my PHP code. I was following this tutorial to learn how to return the row count of all of my database tables at once in MySQL. However, this tutorial just uses vanilla prepared statements instead of PDO, so I’m a little bit confused on how to translate it over to my own PHP script.
The tutorial teaches how to construct some code in the general form of:
SELECT ...some stuff getting table rows... INTO @sql FROM (SELECT ...some subquery getting table names....) table_list
and then says to run:
PREPARE s FROM @sql; EXECUTE s; DEALLOCATE PREPARE s;
Now normally I would just do something along the lines of:
$s = $db->prepare($sqlString); $s->execute();
to prepare and execute my SQL query. But this tutorial is using
INTO @sql in the middle of their query and then executing
@sql. What is my equivalent with PDO? How do I store a query into a user-defined variable and then execute it in PHP?
Thank you for the help!