<?php
	/**
	* This interface holds all common methods between different database adapters.
	*
	* @copyright Trusto Tech 2015-2016
	* @author  Taha Sayyad <info@trustotech.com>
	* @package System\Database\Adapters
	*/
	interface DBAdapterInterface {

		/**
		* This method is reponsible for invoking the database.<br />
		* All database query features can be used with this method (insert, update, delete, join, etc).
		*
		* @param string $query The query string that will be executed
		* @return mixed For SELECT statements the method returns a resource on success, or false on error.
		*		  For UPDATE, INSERT, DELETE, DROP, etc the method returns true on success or false on error.
		*/
		public function query($query);

		/**
		* This methods takes a result from a previously executed <strong>SELECT</strong> query and returns the number of rows found.
		*
		* @param array $result Result of a previously executed SELECT query
		* @return int Number of rows found
		*/
		public function rowsno($result);

		/**
		* Invokes the database server by changing its charset to UTF-8 to accept RTL characters (ie: Arabic).<br />
		* <strong>Note:</strong>: must be used before executing the usual queries.
		*/
		public function setNames();

		/**
		* Fetch a result from a query resource.
		*
		* @param resource $result Result resource of a previously executed SELECT query.
		* @return array An array of strings that corresponds to the fetched row, or FALSE if there are no more rows. 
		*		  The type of returned array depends on how result_type is defined. By using MYSQL_BOTH (default), you'll get 
		*		  an array with both associative and number indices.
		*/
		public function fetch($result);

		/**
		* Grab the ID generated from the last query.<br />
		* <strong>Note:</strong> Must be used ONLY after a successful INSERT query.
		*
		* @return int The ID generated after a successul INSERT query; 0 if the INSERT query was unsuccessful.
		*/
		public function id();

		/**
		* Fetch a result from a query resource.
		*
		* @param resource $result Result resource of a previously executed SELECT query.
		* @return array An array of strings that corresponds to the fetched row, or FALSE if there are no more rows. 
		*		  You'll get an array with associative indices.
		*/
		public function assoc($result);

		/**
		* Get the resource id of the current opened connection if you are using the MySQL adapter,
		* or the connection object if you are using MySQLi adapter.
		*
		* @return mixed The resource id of the current connection for MySQL or connection object for MySQLi.
		*/
		public function getConnectionObject();

	}