I am relatively new to Joomla and the way they implement an MVC arcitecture. It is slighty different to how I am used to it (Code Igniter, etc) and I am having a few issues simply passing data to the view.
I have created a function in the controller called 'getInitClubs' which sould be run automatically when the page runs, therefore I have made a call to this function from the 'view.html' file.
Here is my code:
Controller function:
public function getInitClubs() {
$model =& $this->getModel('directory');
$init_clubs = $model->clubResults($conds = array());
return $init_clubs;
}
Model Function:
public function clubResults($conds) {
$query = "SELECT * FROM vyj20_contact_details";
if(isset($conds['city'])) {
$query .= " WHERE state = '" . mysql_escape_string($conds['city']) . "'";
}
if(isset($conds['suburb'])) {
$query .= " AND suburb = '" . mysql_escape_string($conds['suburb']) . "'";
}
$this->_db->setQuery($query);
$results = $this->_db->loadObjectList();
return $results;
}
Now i know the model and controller code works, this is not the issue, the issue is actually pulling the results from the controller function 'getInitClubs' and showing them through the view.
How do I call the controller function from the view (like I would on Code Igniter MVC) in order to collect results for display? I have tried and tried but just can't seem to figure it out! Thanks
mysql_*functions in new code. They are no longer maintained and the deprecation process has begun on it. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial.