I am building a site and, as Im looking to develop my OOP skills, have decided to do the majority in OOP. So far I have a templating class (works), an SQL layer (working so far), and a site maitenance class (AAAANT!).
My index.php looks like this:
Code: Select all
include('classes/template.class.php');
include('classes/mysql.class.php');
include('classes/maitenance.class.php');
// template + modular code here
$ops->getNews();
// template code hereNow the class is initialized (the sql layer) before it is used in the maitenance file and the DB connect and select are executed before as well (and tested, there is a full connection to the MySQL server)
Now in the getNews() func I have this:
Code: Select all
function getNews()
{
$mysql->query('SELECT * FROM ' . $this->news_table . ' LIMIT '. $this->num_news, $sql) or die (mysql_error());
$output = '';
while ($row = mysql_fetch_array($sql))
{
$output .= "<h2>{$row['title']} - {$row['date']}</h2>";
$output .= "<p>{$row['maintext']}</p>";
$output .= "<hr /><br />";
}
return $output;
}Question: Is there a specific action to perform to have 2 classes interact?
Thanks and sorry for the long post