Same query on different tables... in one case it returns an error
Briefly

Same query on different tables... in one case it returns an error
"This is the definition of the "DctWebsite" class. <?php namespace Dct; class DctWebsite implements \Ninja\Website { private ?\Ninja\DbTable $newsTable; private ?\Ninja\DbTable $campTable; public function __construct() { $pdo = new \PDO('mysql:host=localhost;dbname=* * * *;charset=utf8', '* * * *', '* * * *'); $this->newsTable = new \Ninja\DbTable($pdo, 'TB_News', 'ID_News', '\Dct\Entity\News', [&$this->campTable]); $this->campTable = new \Ninja\DbTable($pdo, 'TB_Campionato', 'ID_Campionato', '\Dct\Entity\Campionato', [&$this->newsTable]); This is the definition of the "Campionato" entity class."
"Here I am This is the definition of the "News" class: <?php namespace Dct\Controllers; class News { public function __construct(private \Ninja\DbTable $newsTable) { } This is the definition of the "Campionato" class. <?php namespace Dct\Controllers; class Campionato { public function __construct(private \Ninja\DbTable $campTable) { } This is the definition of the "DbTable" class. <?php namespace Ninja; class DbTable { public function __construct(private \PDO $pdo, private string $table, private string $primaryKey, private string $className = '\stdClass', private array $constructorArgs = []) { }"
Two controller classes (News and Campionato) receive a Ninja\DbTable instance via constructor injection. The DbTable class wraps a PDO, table name, primary key, optional entity class name, and constructor arguments for entities. DctWebsite constructs two DbTable instances for TB_News and TB_Campionato and passes references to each other's table in constructorArgs, creating a circular dependency. The Campionato entity holds a news table and provides getNews() to call find by ID_Campionato. The News entity holds a camp table and lazily loads the camp via getCamp(). The circular references can result in uninitialized references during construction.
[
|
]