Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Description of class
- *
- * @author manuelfernandez
- */
- namespace ManuelFernandez;
- class engine
- {
- private $hostname;
- private $username;
- private $password;
- private $database;
- private $connection;
- private $selection;
- private $functions = array(
- 'connect' => 'mysql_connect',
- 'select_db' => 'mysql_select_db',
- 'query' => 'mysql_query',
- 'free_result' => 'mysql_free_result',
- 'result' => 'mysql_result',
- 'num_rows' => 'mysql_num_rows',
- 'fetch_array' => 'mysql_fetch_array',
- 'fetch_assoc' => 'mysql_fetch_assoc'
- );
- private $fetchtypes = array(
- 'assoc' => 'MYSQL_ASSOC',
- 'both' => 'MYSQL_BOTH'
- );
- final public function MFconfigurate()
- {
- global $core;
- if(file_exists('app/config.php'))
- {
- include('app/config.php');
- $this->hostname = $CONFIG['mysql_hostname'];
- $this->username = $CONFIG['mysql_username'];
- $this->password = $CONFIG['mysql_password'];
- $this->database = $CONFIG['mysql_database'];
- }
- else
- {
- $core->MFerror('config');
- }
- }
- final public function connect()
- {
- global $core;
- $this->connection = $this->functions['connect']($this->hostname, $this->username, $this->password) or die(mysql_error());
- $this->selection = $this->functions['select_db']($this->database) or die(mysql_error());
- if(is_resource($this->connection) && $this->selection == true)
- {
- $this->connection = true;
- $this->selection = true;
- }
- else
- {
- $core->MFerror('mysql');
- }
- }
- final public function secure($str)
- {
- return mysql_real_escape_string(strip_tags(htmlspecialchars($str)));
- }
- final public function executeQuery($sql)
- {
- return $this->functions['query']($sql);
- }
- final public function fetch_array($sql, $fetchtype)
- {
- return $this->functions['fetch_array']($this->functions['query']($sql, $this->fetchtypes[$fetchtype]));
- }
- final public function fetch_assoc($sql)
- {
- return $this->functions['fetch_assoc']($this->functions['query']($sql));
- }
- final public function num_rows($sql)
- {
- return $this->functions['num_rows']($sql);
- }
- final public function result($sql, $int)
- {
- return $this->functions['result']($this->functions['query']($sql), $int);
- }
- final public function free_result($sql)
- {
- return $this->functions['free_result']($sql);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement