mirror of
https://github.com/dg/dibi.git
synced 2025-08-06 06:07:39 +02:00
added low-level methods createResultDriver() and DibiConnection::createResultSet()
This commit is contained in:
@@ -131,7 +131,7 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
throw new DibiDriverException(ibase_errmsg(), ibase_errcode(), $sql);
|
throw new DibiDriverException(ibase_errmsg(), ibase_errcode(), $sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
return is_resource($this->resultSet) ? clone $this : NULL;
|
return is_resource($this->resultSet) ? $this->createResultDriver($this->resultSet) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -251,6 +251,20 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Result set driver factory.
|
||||||
|
* @param resource
|
||||||
|
* @return IDibiResultDriver
|
||||||
|
*/
|
||||||
|
public function createResultDriver($resource)
|
||||||
|
{
|
||||||
|
$res = clone $this;
|
||||||
|
$res->resultSet = $resource;
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* SQL ********************/
|
/********************* SQL ********************/
|
||||||
|
|
||||||
|
|
||||||
|
@@ -99,7 +99,7 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
throw new DibiDriverException(mssql_get_last_message(), 0, $sql);
|
throw new DibiDriverException(mssql_get_last_message(), 0, $sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
return is_resource($this->resultSet) ? clone $this : NULL;
|
return is_resource($this->resultSet) ? $this->createResultDriver($this->resultSet) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -192,6 +192,20 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Result set driver factory.
|
||||||
|
* @param resource
|
||||||
|
* @return IDibiResultDriver
|
||||||
|
*/
|
||||||
|
public function createResultDriver($resource)
|
||||||
|
{
|
||||||
|
$res = clone $this;
|
||||||
|
$res->resultSet = $resource;
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* SQL ****************d*g**/
|
/********************* SQL ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
@@ -101,7 +101,7 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver, IDibiResult
|
|||||||
throw new DibiDriverException($info[0]['message'], $info[0]['code'], $sql);
|
throw new DibiDriverException($info[0]['message'], $info[0]['code'], $sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
return is_resource($this->resultSet) ? clone $this : NULL;
|
return is_resource($this->resultSet) ? $this->createResultDriver($this->resultSet) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -194,6 +194,20 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver, IDibiResult
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Result set driver factory.
|
||||||
|
* @param resource
|
||||||
|
* @return IDibiResultDriver
|
||||||
|
*/
|
||||||
|
public function createResultDriver($resource)
|
||||||
|
{
|
||||||
|
$res = clone $this;
|
||||||
|
$res->resultSet = $resource;
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* SQL ****************d*g**/
|
/********************* SQL ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
@@ -165,7 +165,7 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
throw new DibiDriverException(mysql_error($this->connection), mysql_errno($this->connection), $sql);
|
throw new DibiDriverException(mysql_error($this->connection), mysql_errno($this->connection), $sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
return is_resource($this->resultSet) ? clone $this : NULL;
|
return is_resource($this->resultSet) ? $this->createResultDriver($this->resultSet) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -271,6 +271,20 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Result set driver factory.
|
||||||
|
* @param resource
|
||||||
|
* @return IDibiResultDriver
|
||||||
|
*/
|
||||||
|
public function createResultDriver($resource)
|
||||||
|
{
|
||||||
|
$res = clone $this;
|
||||||
|
$res->resultSet = $resource;
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* SQL ****************d*g**/
|
/********************* SQL ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
@@ -162,7 +162,7 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
throw new DibiDriverException(mysqli_error($this->connection), mysqli_errno($this->connection), $sql);
|
throw new DibiDriverException(mysqli_error($this->connection), mysqli_errno($this->connection), $sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
return is_object($this->resultSet) ? clone $this : NULL;
|
return is_object($this->resultSet) ? $this->createResultDriver($this->resultSet) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -268,6 +268,20 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Result set driver factory.
|
||||||
|
* @param mysqli_result
|
||||||
|
* @return IDibiResultDriver
|
||||||
|
*/
|
||||||
|
public function createResultDriver(mysqli_result $resource)
|
||||||
|
{
|
||||||
|
$res = clone $this;
|
||||||
|
$res->resultSet = $resource;
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* SQL ****************d*g**/
|
/********************* SQL ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
@@ -104,7 +104,7 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
|||||||
throw new DibiDriverException(odbc_errormsg($this->connection) . ' ' . odbc_error($this->connection), 0, $sql);
|
throw new DibiDriverException(odbc_errormsg($this->connection) . ' ' . odbc_error($this->connection), 0, $sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
return is_resource($this->resultSet) ? clone $this : NULL;
|
return is_resource($this->resultSet) ? $this->createResultDriver($this->resultSet) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -211,6 +211,20 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Result set driver factory.
|
||||||
|
* @param resource
|
||||||
|
* @return IDibiResultDriver
|
||||||
|
*/
|
||||||
|
public function createResultDriver($resource)
|
||||||
|
{
|
||||||
|
$res = clone $this;
|
||||||
|
$res->resultSet = $resource;
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* SQL ****************d*g**/
|
/********************* SQL ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
@@ -111,7 +111,7 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
throw new DibiDriverException($err['message'], $err['code'], $sql);
|
throw new DibiDriverException($err['message'], $err['code'], $sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
return is_resource($this->resultSet) ? clone $this : NULL;
|
return is_resource($this->resultSet) ? $this->createResultDriver($this->resultSet) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -207,6 +207,20 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Result set driver factory.
|
||||||
|
* @param resource
|
||||||
|
* @return IDibiResultDriver
|
||||||
|
*/
|
||||||
|
public function createResultDriver($resource)
|
||||||
|
{
|
||||||
|
$res = clone $this;
|
||||||
|
$res->resultSet = $resource;
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* SQL ****************d*g**/
|
/********************* SQL ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
@@ -126,7 +126,7 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver, IDibiResultDriver
|
|||||||
throw new DibiDriverException("SQLSTATE[$err[0]]: $err[2]", $err[1], $sql);
|
throw new DibiDriverException("SQLSTATE[$err[0]]: $err[2]", $err[1], $sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
return clone $this;
|
return $this->createResultDriver($this->resultSet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,6 +224,20 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver, IDibiResultDriver
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Result set driver factory.
|
||||||
|
* @param PDOStatement
|
||||||
|
* @return IDibiResultDriver
|
||||||
|
*/
|
||||||
|
public function createResultDriver(PDOStatement $resource)
|
||||||
|
{
|
||||||
|
$res = clone $this;
|
||||||
|
$res->resultSet = $resource;
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* SQL ****************d*g**/
|
/********************* SQL ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
@@ -131,7 +131,7 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
throw new DibiDriverException(pg_last_error($this->connection), 0, $sql);
|
throw new DibiDriverException(pg_last_error($this->connection), 0, $sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
return is_resource($this->resultSet) && pg_num_fields($this->resultSet) ? clone $this : NULL;
|
return is_resource($this->resultSet) && pg_num_fields($this->resultSet) ? $this->createResultDriver($this->resultSet) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -241,6 +241,20 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Result set driver factory.
|
||||||
|
* @param resource
|
||||||
|
* @return IDibiResultDriver
|
||||||
|
*/
|
||||||
|
public function createResultDriver($resource)
|
||||||
|
{
|
||||||
|
$res = clone $this;
|
||||||
|
$res->resultSet = $resource;
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* SQL ****************d*g**/
|
/********************* SQL ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
@@ -130,7 +130,7 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
throw new DibiDriverException($msg, sqlite_last_error($this->connection), $sql);
|
throw new DibiDriverException($msg, sqlite_last_error($this->connection), $sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
return is_resource($this->resultSet) ? clone $this : NULL;
|
return is_resource($this->resultSet) ? $this->createResultDriver($this->resultSet) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -218,6 +218,20 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Result set driver factory.
|
||||||
|
* @param resource
|
||||||
|
* @return IDibiResultDriver
|
||||||
|
*/
|
||||||
|
public function createResultDriver($resource)
|
||||||
|
{
|
||||||
|
$res = clone $this;
|
||||||
|
$res->resultSet = $resource;
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* SQL ****************d*g**/
|
/********************* SQL ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
@@ -120,7 +120,7 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
throw new DibiDriverException($this->connection->lastErrorMsg(), $this->connection->lastErrorCode(), $sql);
|
throw new DibiDriverException($this->connection->lastErrorMsg(), $this->connection->lastErrorCode(), $sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->resultSet instanceof SQLite3Result ? clone $this : NULL;
|
return $this->resultSet instanceof SQLite3Result ? $this->createResultDriver($this->resultSet) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -208,6 +208,20 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Result set driver factory.
|
||||||
|
* @param SQLite3Result
|
||||||
|
* @return IDibiResultDriver
|
||||||
|
*/
|
||||||
|
public function createResultDriver(SQLite3Result $resource)
|
||||||
|
{
|
||||||
|
$res = clone $this;
|
||||||
|
$res->resultSet = $resource;
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* SQL ****************d*g**/
|
/********************* SQL ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
@@ -352,6 +366,7 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
*/
|
*/
|
||||||
public function free()
|
public function free()
|
||||||
{
|
{
|
||||||
|
$this->resultSet->finalize();
|
||||||
$this->resultSet = NULL;
|
$this->resultSet = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -340,7 +340,7 @@ class DibiConnection extends DibiObject
|
|||||||
|
|
||||||
dibi::$sql = $sql;
|
dibi::$sql = $sql;
|
||||||
if ($res = $this->driver->query($sql)) { // intentionally =
|
if ($res = $this->driver->query($sql)) { // intentionally =
|
||||||
$res = new DibiResult($res, $this->config['result']);
|
$res = $this->createResultSet($res);
|
||||||
} else {
|
} else {
|
||||||
$res = $this->driver->getAffectedRows();
|
$res = $this->driver->getAffectedRows();
|
||||||
}
|
}
|
||||||
@@ -466,6 +466,18 @@ class DibiConnection extends DibiObject
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Result set factory.
|
||||||
|
* @param IDibiResultDriver
|
||||||
|
* @return DibiResult
|
||||||
|
*/
|
||||||
|
public function createResultSet(IDibiResultDriver $resultDriver)
|
||||||
|
{
|
||||||
|
return new DibiResult($resultDriver, $this->config['result']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* fluent SQL builders ****************d*g**/
|
/********************* fluent SQL builders ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user