What the best way to reduce the number of queries when the Class DAO have methods that use the same result?
问题 I have a helper class DAO (I do not know if is OK have this) for get Categories from MySQL DB, the struct is basically this: <?php require_once '../include/PDOConnectionFactory.php'; class CategoryDAO extends PDOConnectionFactory { /** * * @var PDO $conn */ private $conn; public function __construct() { $this->conn = PDOConnectionFactory::getConnection(); } } ?> This class have these methods (some then): getMaxLevel() getAllCategories() getAllCategoriesOfLevel($level) haveChildCategory(