Reorganize db drivers

This commit is contained in:
Timothy Warren 2012-04-09 15:41:48 -04:00
parent d0a50e9c87
commit a43f04efd1
8 changed files with 142 additions and 129 deletions

View File

@ -497,126 +497,4 @@ SQL;
return $output_sql;
}
}
// --------------------------------------------------------------------------
/**
* Firebird result class to emulate PDOStatement Class
*/
class Firebird_Result {
private $statement;
/**
* Create the object by passing the resource for
* the query
*
* @param resource $link
*/
public function __construct($link)
{
$this->statement = $link;
}
// --------------------------------------------------------------------------
/**
* Emulate PDO fetch public function
*
* @param int $fetch_style
* @return mixed
*/
public function fetch($fetch_style=PDO::FETCH_ASSOC, $statement=NULL)
{
if ( ! is_null($statement))
{
$this->statement = $statement;
}
switch($fetch_style)
{
case PDO::FETCH_OBJ:
return fbird_fetch_object($this->statement, IBASE_FETCH_BLOBS);
break;
case PDO::FETCH_NUM:
return fbird_fetch_row($this->statement, IBASE_FETCH_BLOBS);
break;
default:
return fbird_fetch_assoc($this->statement, IBASE_FETCH_BLOBS);
break;
}
}
// --------------------------------------------------------------------------
/**
* Emulate PDO fetchAll public function
*
* @param int $fetch_style
* @return mixed
*/
public function fetchAll($fetch_style=PDO::FETCH_ASSOC, $statement=NULL)
{
$all = array();
while($row = $this->fetch($fetch_style, $statement))
{
$all[] = $row;
}
$this->result = $all;
return $all;
}
// --------------------------------------------------------------------------
/**
* Run a prepared statement query
*
* @param array $args
* @return bool
*/
public function execute($args)
{
//Add the prepared statement as the first parameter
array_unshift($args, $this->statement);
// Let php do all the hard stuff in converting
// the array of arguments into a list of arguments
// Then pass the resource to the constructor
$this->__construct(call_user_func_array('fbird_execute', $args));
return $this;
}
// --------------------------------------------------------------------------
/**
* Return the number of rows affected by the previous query
*
* @return int
*/
public function rowCount()
{
return fbird_affected_rows();
}
// --------------------------------------------------------------------------
/**
* Method to emulate PDO->errorInfo / PDOStatement->errorInfo
*
* @return array
*/
public function errorInfo()
{
$code = fbird_errcode();
$msg = fbird_errmsg();
return array(0, $code, $msg);
}
}
// End of firebird.php
// End of firebird_driver.php

View File

@ -0,0 +1,134 @@
<?php
/**
* OpenSQLManager
*
* Free Database manager for Open Source Databases
*
* @author Timothy J. Warren
* @copyright Copyright (c) 2012
* @link https://github.com/aviat4ion/OpenSQLManager
* @license http://philsturgeon.co.uk/code/dbad-license
*/
// --------------------------------------------------------------------------
/**
* Firebird result class to emulate PDOStatement Class
*/
class Firebird_Result {
private $statement;
/**
* Create the object by passing the resource for
* the query
*
* @param resource $link
*/
public function __construct($link)
{
$this->statement = $link;
}
// --------------------------------------------------------------------------
/**
* Emulate PDO fetch public function
*
* @param int $fetch_style
* @return mixed
*/
public function fetch($fetch_style=PDO::FETCH_ASSOC, $statement=NULL)
{
if ( ! is_null($statement))
{
$this->statement = $statement;
}
switch($fetch_style)
{
case PDO::FETCH_OBJ:
return fbird_fetch_object($this->statement, IBASE_FETCH_BLOBS);
break;
case PDO::FETCH_NUM:
return fbird_fetch_row($this->statement, IBASE_FETCH_BLOBS);
break;
default:
return fbird_fetch_assoc($this->statement, IBASE_FETCH_BLOBS);
break;
}
}
// --------------------------------------------------------------------------
/**
* Emulate PDO fetchAll public function
*
* @param int $fetch_style
* @return mixed
*/
public function fetchAll($fetch_style=PDO::FETCH_ASSOC, $statement=NULL)
{
$all = array();
while($row = $this->fetch($fetch_style, $statement))
{
$all[] = $row;
}
$this->result = $all;
return $all;
}
// --------------------------------------------------------------------------
/**
* Run a prepared statement query
*
* @param array $args
* @return bool
*/
public function execute($args)
{
//Add the prepared statement as the first parameter
array_unshift($args, $this->statement);
// Let php do all the hard stuff in converting
// the array of arguments into a list of arguments
// Then pass the resource to the constructor
$this->__construct(call_user_func_array('fbird_execute', $args));
return $this;
}
// --------------------------------------------------------------------------
/**
* Return the number of rows affected by the previous query
*
* @return int
*/
public function rowCount()
{
return fbird_affected_rows();
}
// --------------------------------------------------------------------------
/**
* Method to emulate PDO->errorInfo / PDOStatement->errorInfo
*
* @return array
*/
public function errorInfo()
{
$code = fbird_errcode();
$msg = fbird_errmsg();
return array(0, $code, $msg);
}
}
// End of firebird_result.php

View File

@ -221,4 +221,4 @@ class MySQL extends DB_PDO {
return '`'.implode('`.`', $hiers).'`';
}
}
//End of mysql.php
//End of mysql_driver.php

View File

@ -188,4 +188,4 @@ class ODBC extends DB_PDO {
return '';
}
}
// End of odbc.php
// End of odbc_driver.php

View File

@ -281,4 +281,4 @@ SQL;
return '';
}
}
//End of pgsql.php
//End of pgsql_driver.php

View File

@ -312,4 +312,4 @@ SQL;
return $output_sql;
}
}
//End of sqlite.php
//End of sqlite_driver.php

View File

@ -56,9 +56,10 @@ foreach(pdo_drivers() as $d)
continue;
}
$src_file = "{$src_path}{$d}.php";
// Load by driver folder
$src_dir = "{$src_path}{$d}";
if(is_file($src_file))
if(is_dir($src_dir))
{
array_map('do_include', glob($src_path.$d.'/*.php'));
require_once("{$test_path}{$d}.php");

Binary file not shown.