I'm trying to use OOP to make a content management system. I have a DB class that makes db connections, runs queries, etc. I have another class called menu that is supposed to query my database (via the db class) and write my menu information on the screen. Among other things, I call the printMenu() function:
function printMenu()
{
$this->getData();
echo "<ul>";
while ($row = $this->fetchObject())
{
echo "<li>$row->PageName</li>";
}
echo "</ul>";
}
This calls getData():
[code=php]
function getData()
{
$db = new DB('localhost', 'mark', 'mywebsite', 'hydra_cms');
$myDb = $db->open();
if (!myDb)
{
die($db->error());
}
$sql = "select PageID, PageName, SiteID, LevelNumber from PageTable where SiteID = '$siteNumber' AND LevelNumber = '$levelNumber' ORDER BY PageName ASC";
$myResult = $db->query($sql);
if (!$myResult)
{
die($db->error());
}
}
I get the following error:
Fatal error: Call to undefined function: open()
What is wrong with this? How can I get it to work?
Thanks in advance!