/ Published in: PHP

Expand |
Embed | Plain Text
class Database { private $dbName = "mcms"; private $host = "localhost"; private $username = "moroch"; private $password = "w1d33y3"; private $connected; public function __construct() { } { if (!self::$instance) { self::$instance = new Database(); } return self::$instance; } public function connect() { try { if (!$this->connected) throw new Exception("Could not connect to MySql server."); } catch (Exception $e) { } } public function selectDB() { } public function execute($sql) { } }
Comments

You need to login to post a comment.
Thank you for the contribution, but I am unsure what you mean by Pure MVC... MVC is a design pattern that uses 3 components Model... which is generally a class definition of database table, the View which isused to handle the display of the data provided by the model, and of course the controller, which basically handles requests and routes the request to the proper controller and loads the correct view.. This class here, is a a singleton .. which means it will only allow a single instance of the object to exist at any given time. This pattern is often used in an MVC architecture, but it is not really anything to do with MVC as a whole... Good code though, so please dont take this the wrong way... very useful.
Cheers
Maybe I should have come up with a better title or offered a description. Frankly, the code was meant for my developers particular usage alone and should probably have been set to private (I'm somewhat new to Snipplr.com). This code is meant for my Flex developers using PureMVC and WebORB. It's usage is for working with the AS3 code generated by WebORB's management tool and our workflow.