Source of packages/Combie/Db/Driver/Mysql.php
<?php
/**
* MySQL Driver
*
* @filesource
* @author Combie <uli@combie.de>
* @version $Id$
* @package Combie
* @subpackage DB
*/
namespace Combie\Db\Driver ;
use Combie\Db;
/**
* MySQL Driver
*
* @package Combie
* @subpackage DB
*/
class Mysql implements \Combie\Idb
{
/**
* MySQL Conncet Handle
*
*/
private $handle = FALSE;
public function __construct($dburl)
{
if(!function_exists('mysql_connect'))
Throw new Db\DbException('mysql Erweiterung nicht geladen');
$path = parse_url($dburl);
$port = isset($path['port'])?':'.$path['port']:'';
$server = $path['host'].$port;
$this->handle = @mysql_connect($server,$path['user'] ,$path['pass'], TRUE);
if(FALSE === $this->handle) Throw new Db\DbException(mysql_error());
$select = mysql_select_db(trim($path['path'],"/"),$this->handle);
if(FALSE === $select) Throw new db\DbException(mysql_error());
}
public function __destruct()
{
if(is_resource($this->handle))
mysql_close($this->handle);
}
public function query($query)
{
$res = @mysql_query($query,$this->handle);
if(FALSE === $res) Throw new db\DbException(mysql_error());
return new Db\Result($this,$res);
}
public function fetch($res)
{
return mysql_fetch_assoc($res);
}
public function free($res)
{
return mysql_free_result($res);
}
public function numrows($res)
{
return mysql_num_rows($res);
}
public function insertid($res)
{
return mysql_insert_id($res);
}
public function seek($res,$index)
{
return mysql_data_seek ($res,$index);
}
}
?>