Jump to content

Search the Community

Showing results for tags 'render'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. hello everyone. i'm trying to make an mvc website based on this example http://anantgarg.com...amework-part-1/ Instead of using a common sql connection i have extend the model with a PDO. i made a class called PDOconnection and extends the model. When i load the page i'm getting this error message Fatal error: Call to a member function render() on a non-object in /Applications/MAMP/htdocs/project/library/controller.class.php on line 47 and when i made comment the model is loading the template. what my doing wrong? where is my code controller.class.php <?php class Controller { protected $_model; protected $_controller; protected $_action; protected $_template; function __construct($model, $controller, $action) { $this->_controller = $controller; $this->_action = $action; $this->_model = $model; //& = & $this->$model = new $model; $this->_template = new Template($controller,$action); } function set($name,$value) { $this->_template->set($name,$value); } function __destruct() { print_r($this->_template->render()); } } model.class.php <?php class Model extends PDOconnection { protected $_model; protected $_PDOconnection; protected $_result; private $_connection; function __construct() { $this->_PDOconnection = $this->PDO_connect(DB_HOST,DB_USER,DB_PASSWORD); $this->_model = get_class($this); $this->_table = strtolower($this->_model)."s"; } function __destruct() { } } pdoconnection.class.php <?php class PDOconnection { protected $_dbh; protected $_result; /** Connects to database **/ function PDO_connect($host, $username,$password) { try { $this->_dbh = new PDO($host, $username, $password); $this->_dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); print_r($this->_dbh); } catch (PDOException $e) { /** * If any error occur will trying to connect to the database it will store it on the errorlog file. * **/ error_log("Database is down!".date("d-F-Y h:i:s a", time()), 0); die(); } return $this->_dbh; } /** Disconnects from database **/ function disconnect() { $this->_dbh = null; } } template.class.php <?php class Template { protected $variables = array(); protected $_controller; protected $_action; function __construct($controller,$action) { $this->_controller = $controller; $this->_action = $action; } /** Set Variables **/ function set($name,$value) { $this->variables[$name] = $value; } /** Display Template **/ function render() { extract($this->variables); if (file_exists(ROOT . DS . 'application' . DS . 'views' . DS . $this->_controller . DS . 'header.php')) { include (ROOT . DS . 'application' . DS . 'views' . DS . $this->_controller . DS . 'header.php'); } else { include (ROOT . DS . 'application' . DS . 'views' . DS . 'header.php'); } include (ROOT . DS . 'application' . DS . 'views' . DS . $this->_controller . DS . $this->_action . '.php'); if (file_exists(ROOT . DS . 'application' . DS . 'views' . DS . $this->_controller . DS . 'footer.php')) { include (ROOT . DS . 'application' . DS . 'views' . DS . $this->_controller . DS . 'footer.php'); } else { include (ROOT . DS . 'application' . DS . 'views' . DS . 'footer.php'); } } }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.