Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * __ .__ __
- * _____________ |__|_ _ _|__| _____/ |_ ___________
- * \____ \_ __ \| \ \/ \/ / |/ \ __\/ __ \_ __ \
- * | |_> > | \/| |\ /| | | \ | \ ___/| | \/
- * | __/|__/\__| | \/\_/ |__|___| /__| \___ >__|
- * |__| \______| \/ \/
- *
- * Flexible and easy-to-use PHP framework
- */
- class Engine extends Functions {
- /*
- * Variables
- */
- private $host, $user, $pass, $dbname, $port, $enabled, $link;
- /*
- * Initalise
- */
- final public function initalise($host, $user, $pass, $dbname, $port) {
- if(!$this->enabled) {
- $this->host = $host;
- $this->user = $user;
- $this->pass = $pass;
- $this->dbname = $dbname;
- $this->port = $port;
- $this->link = mysql_pconnect($this->host, $this->user, $this->pass);
- if(mysql_select_db($this->dbname, $this->link)) {
- $this->enabled = true;
- } else {
- parent::throwError("Engine Error", "Failed to connect to server host.");
- }
- }
- }
- /*
- * Filter
- */
- final public function filter($string) {
- return mysql_real_escape_string($string);
- }
- /*
- * Handlers
- */
- final public function close() {
- if($this->enabled) {
- mysql_close();
- $this->enabled = false;
- } else {
- parent::throwError("Engine Error", "There is no established connection to close.");
- }
- }
- final public function send($string) {
- if($this->enabled) {
- $this->filter($string);
- mysql_query($string);
- } else {
- parent::throwError("Engine Error", "Failed to send to the specified database. Info: " . mysql_error());
- }
- }
- }
- ?>
Add Comment
Please, Sign In to add comment