Driver.class.php 1.39 KB
<?php
/**
 * 数据库操作 
 * 
 * example:
 * <pre>
 * 
 * </pre>
 * 
 * @name Util_Dao_Db
 * @version 40  (2009-3-4 上午10:39:01)
 * @package Q.Dao.Db
 * @author peter.zyliu liuziyang@zadooo.com
 * @since 1.0
 */
class Util_Dao_Db_Driver
{
	
	/**
	 * Enter description here...
	 *
	 * @var Zend_Db
	 */
	private $pdo;
	
	/**
	 * 初始化
	 *
	 * @param Array $params
	 * @param String $drivers
	 */
	public function __construct($params, $drivers = 'PDO_MYSQL')
	{
		$this->pdo = Util_Db::factory($drivers, $params);
	}
	
	/**
	 * 
	 * 取得语句对象
	 *
	 * @param String $sql
	 * @param array $parameterMap 数组
	 * @return Util_Dao_Db_PdoQuery
	 */
	public function stmt($sql, $parameterMap = array())
	{
		return new Util_Dao_Db_PdoQuery($this->pdo, $sql, $parameterMap);
	}
	
	/**
	 * @return Zend_Db_Adapter_Abstract
	 */
	public function zendDB()
	{
		return $this->pdo;
	}
	
	/**
	 * 开始事务
	 *
	 */
	public function beginTransaction()
	{
		$this->pdo->beginTransaction();
	}
	
	/**
	 * 提交
	 *
	 */
	public function commit()
	{
		$this->pdo->commit();
	}
	/**
	 * 回滚
	 *
	 */
	public function rollBack()
	{
		$this->pdo->rollBack();
	}
	
	/**
	 * 关闭连接
	 *
	 */
	public function close()
	{
		$this->pdo->closeConnection();
	}
	
	/**
	 * 是否链接
	 * @param  int $attr
	 */
	public function isConnected()
	{
		$this->pdo->__wakeup();
		return $this->pdo->isConnected();
	}
}