Starter extends Mysql {
public $settings, $fetchsettings, $pagenr, $fetchpages, $menuq, $pagesq;
public $menustr;
public $fetchmenu;
public $options, $tag;
public $i = 0;
public function Start() {
$this->makeconnection("","","","");
// Load Default Settings
$this->settings = $this->query("SELECT * FROM settings WHERE id='1'");
$this->fetchsettings = mysql_fetch_array($this->settings);
// Load Pages
$this->pagenr = mysql_real_escape_string($_GET['page']);
if($this->pagenr == "") { $this->pagenr=1; }
$this->pagesq = $this->query("SELECT * FROM pages WHERE id='".$this->pagenr."'");
$this->fetchpages = mysql_fetch_array($this->pagesq);
// Load Menu
The error you are receiving is because $Starter has not been declared within the template, and is not an object with an accessable showmenu() method (since it hasn't been constructed).
Starter either needs to be passed into the GenerateMenu method, or constructed or passed into either the Template or View object upon construction. This would then require access under $this->Starter instead. This can be enforced with typehinting if required:
PHP Code:
public function GenerateMenu(Starter $starter) {
// ....
If the Starter::showmenu() is from a higher interface, typehint on that instead of a lower level class.
Edit:
Oh well nvm. I guess I shouldn't have left this thread open when I went out.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
What??? Your topic was 46 minutes old! You don't think people sit here on the forums with an itchy trigger finger pecking away at the ol' F5 key... do you? Patience...
Catchable fatal error: Argument 1 passed to Template::GenerateMenu() must be an instance of Starter, none given, called in /home/server/public_html/styles/default/index.tpl on line 108 and defined in /home/server/public_html/includes/template.php on line 6
Great to hear, did you end up passing $Starter into the GenerateMenu(), or did you end up instantiating inside of the constructor for it?
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
public function __construct($Model) {
$this->Model = $Model;
}
}
Controller:
Code:
class Controller {
public $View, $Model;
public function __construct($Model, $View) {
$this->Model = $Model;
$this->View = $View;
}
public function SwitchCase($Case) {
$this->Case = $Case;
switch($this->Case) {
case "Start":
$this->Model->Start();
break;
case "ShowMenu":
$this->Model->showmenu();
break;
case "MakeConnection":
$this->Model->makeconnection();
break;
}