<?php
/**
* This file is part of the easy-CMS project.
* easy-CMS is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* 
* easy-CMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with easy-CMS; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

include_once('config.inc.php');
include_once('classes/core/CoreObject.class.php');

class DBConnection extends CoreObject {

	/**
	 * Object containing db data for SQL transactions.
	 *
	 * @var string
	 */
	var $dbData;

	/**
	 * @var string
	 */
  var $dbmsType;

	/**
	 * @var integer the last auto increment value generated
	 */
  var $lastId;

	/**
	 * Variable containing the latest error.
	 *
	 * The possible values of this var are depending on the DBMS used (here MySQL)
	 * The string can generally be retrieved using the $lastId var value.
	 *
	 * @var	string
	 */
  var $lastError;

	/**
	 * Variable containing the number of affected rows.
	 *
	 * The possible values of this var are depending on the DBMS used (here MySQL)
	 * The integer can generally be retrieved using the $affectedRows var value.
	 *
	 * @var integer
	 */
	var $affectedRows;

	/**
	 * Number of rows returned by last query
	 *
	 * @var integer;
	 */
	var $numRows;

	/**
	 * @var integer
	 */
  var $errNo;

	/**
	 * @var string
	 */
	var $errMsg;

	/**
	* Interface for DBConnections classes
	*
	* @param  integer Specifies the type of the connection
	*                 
	*/
  function DBConnection($dbms, &$dbData) {
		$this->dbmsType = $dbms;
		$this->dbData   = &$dbData;
  }

	/**
	* Get the Current DBMS
	*
	* @return integer Predefined constant
	*/
  function getDBMSType() {
    return $this->dbmsType;
  }

  function getDBMSData() {
    return $this->dbData;
  }
  
  function connect() {
  }

  function disconnect() {
  }

  function sendQuery($sql) {
  }

  function fetchArray(&$array) {
  }

	function fetchRow(&$array) {
	}
	
	/**
	 * Gets Last Error
	 *
	 * Error generated by last query
	 *
	 * @return string
	 */
	function getLastError() {
		return $this->lastError;
	}

	/**
	 * Sets Last Error
	 *
	 * Error generated by last query
	 *
	 * @param string $error
	 * @final
	 * @todo check for uselessness
	 */
	function setLastError($error) {
		$this->lastError = $error;
	}

	/**
	 * Gets Error Number
	 *
	 * Error code generated by last query
	 *
	 * @return integer
	 * @final
	 */
	function getErrNo() {
		return $this->errNo;
	}

	/**
	 * Sets Error Number
	 *
	 * Error code generated by last query
	 *
	 * @param integer $errNo
	 * @final
	 */
	function setErrNo($errNo) {
		$this->errNo = $errNo;
	}

	/**
	 * Gets Error Message
	 *
	 * Error message generated by last query
	 *
	 * @return string
	 * @final
	 */
	function getErrMsg() {
		return $this->errMsg;
	}

	/**
	 * Sets Error Message
	 *
	 * Error message generated by last query
	 *
	 * @param string $errMsg
	 * @final
	 */
	function setErrMsg($errMsg) {
		$this->errMsg = $errMsg;
	}

	/**
	 * Gets Number of Rows
	 *
	 * Number of rows returned by last query
	 *
	 * @return integer
	 * @final
	 */
	function getNumRows() {
		return $this->numRows;
	}

	/**
	 * Sets Number of Rows
	 *
	 * Number of rows returned by last query
	 *
	 * @param integer $numRows
	 * @final
	 */
	function setNumRows($numRows) {
		$this->numRows = $numRows;
	}

	/**
	 * Gets Affected Rows
	 *
	 * Number of affected rows by last query
	 *
	 * @return integer
	 * @final
	 */
	function getAffectedRows(){
		return $this->affectedRows;
	}

	/**
	 * Sets Affected Rows
	 *
	 * Number of affected rows by last query
	 *
	 * @param integer $affectedRows
	 * @final
	 */
	function setAffectedRows($affectedRows) {
		$this->affectedRows = $affectedRows;
	}
	
	/**
	 * Gets Last Id
	 *
	 * Last auto incremented Id
	 *
	 * @return integer
	 * @final
	 */
	function getLastId(){
		return $this->lastId;
	}

	/**
	 * Sets Last Id
	 *
	 * Last auto incremented Id
	 *
	 * @param integer $id
	 * @final
	 */
	function setLastId($id){
		$this->lastId = $id;
	}

}
?>