these are the 2 methods (in different classes) completely similar/equal that “act” on 2 different tables:
public function list() {
return ['title' => 'News list',
'template' => 'ntn7_listnews.html.php',
'variables' => [
'news' => $this->newsTable->findAll()
]
];
}
public function list() {
return ['title' => 'Lista Campionati',
'template' => 'ntn7_listcamp.html.php',
'variables' => [
'camps' => $this->campTable->findAll()
]
];
}
Here is the findAll() method:
public function findAll() {
$stmt = $this->pdo->prepare('SELECT * FROM `' . $this->table . '`');
$stmt->execute();
return $stmt->fetchAll(\PDO::FETCH_CLASS | \PDO::FETCH_PROPS_LATE, $this->className, $this->constructorArgs);
}
…and this is the error that is returned ONLY by the first method (the one that should fetch data from the “news” table):
Database error: SQLSTATE[HY000]: General error: could not call class constructor in/volume1/Web/ntn7/Ninja/DbTable.php:46
Line 46 is the “return $stmt…” line.
I’ve done a few tests and searched the web, but nothing conclusive. The last thing that comes to mind is that there’s a connection with the data structure/type of the two tables. That seems unlikely.
Thanks, Gabriele