<?php
	/**
	* Open a connection with the database server using mysql extension.
	*
	* @deprecated No longer used by internal code and not recommended.
	* @copyright Trusto Tech 2015-2016
	* @author  Taha Sayyad <info@trustotech.com>
	* @package System\Database\Adapters
	*/
	class MySQLAdapter extends DBConnectionParameters implements DBAdapterInterface {

		private $_DBConnection;
		
		public function __construct() {
            parent::_setParameters();
            self::connect();
		}
		
		public function query($query) {
			if (empty($query))
				return false;
			return mysql_query($query);
		}
		
		public function rowsno($result) {
			return mysql_num_rows($result);
		}
		
		public function setNames() {
			mysql_query("SET NAMES 'utf8'"); 
			mysql_query('SET CHARACTER SET utf8'); 
		}
		
		public function fetch($result) {
			return mysql_fetch_array($result);
		}
		
		public function secureInput($input) {
			return mysql_real_escape_string(trim($input));
		}
		
		public function id() {
			return mysql_insert_id();
		}

		public function assoc($result) {
			return mysql_fetch_assoc($result);
		}

		public function getConnectionObject() {
			return $this->_DBConnection;
		}

		private function connect() {
			$this->_DBConnection = @mysql_connect(parent::_getDBHostname(), parent::_getDBUsername(), parent::_getDBPassword());
			if ($this->_DBConnection) {
				if (!mysql_select_db(parent::_getDBName()))
					return false;
			} else
				return false;
		}

	}