How to transfer data from n of tabit in one variable?

Database in which there are three tables - books,movies,music. Trying to transfer all the data from those tables array in variable $catalog

$db = new PDO($dsn, $username, $password);
$results = $db->query("SHOW TABLES FROM data");
$tables = $results->fetchALL(PDO::FETCH_ASSOC);

but then I'm not sure,because $table is an object...

foreach ($tables as $categories) {
$result = $db->query("SELECT * FROM ".$categories);
// trying to SELECT * FROM books / SLECT * FROM movies / SELECT * FROM music depending on the table

$catalog = $results->fetchAll(PDO::FETCH_ASSOC)); // and here I have,in theory,should be the figures from the tables

I would be grateful for any hint!
July 12th 19 at 17:18
2 answers
July 12th 19 at 17:20
A simple foreach to concatenate all.
July 12th 19 at 17:22
Why do you need this vinigret? If it really wants to be perverted - make 3 requests and make array_merge
I have to do all of the data in the website was in filer one array(just bucause)
way train database you have,but I would not want to change the rest of the code ,which in turn depends on the variable $catalog. He looked about like this:
$catalog[101] = [
"title" => "Martin Eden",
"img" => "img/media/martin-eden.jpg",
"genre" => "Philosophical",
"format" => "Paperback",
"year" => 1909,
"category" => "Books",
"authors" => [
"Jack London",

$catalog[302] = [
"title" => "10 000 day"
"img" => "img/media/tool.jpg",
"genre" => "Rock",
"format" => "Vinyl",
"year" => 2006,
"category" => "Music",
"artist" => "Tool"
]; and so on.... - Sherman87 commented on July 12th 19 at 17:25

Find more questions by tags MySQLPHP PDOPHP