I have a simple Connection class which has functions executeQuery(), and close().
Products and basket items are displayed in files shop.php and basket.php.
Originally I was coding as follows in the ShopManager functions
$conn = new Connection(); /* Makes a connection automatically */ $conn->executeQuery($sql); $conn->close();However, several function calls may be required per php page. Since I'm not able to use pconnect this is a problem; I don't want to incurr multiple connection costs on a single page load. So I coded shop.php like follows:
$conn = new Connection(); $manager->getProducts(); $manager->basket->addItem(); $conn->close();Having connection logic in the "view" pages is going to make things less maintainable, reusable, etc, so I would appreciate any alternative suggestions.
On a side note, could anyone explain access modifiers with PHP4? Use of private, public, etc doesn't seem to be supported until v5.