mirror of
https://github.com/dg/dibi.git
synced 2025-08-12 00:54:11 +02:00
- new DibiTable constructor
- moved "tricky clone" from DibiConnection::query to IDibiDriver::query
This commit is contained in:
@@ -279,7 +279,9 @@ class DibiConnection extends /*Nette::*/Object
|
||||
$time = -microtime(TRUE);
|
||||
dibi::notify($this, 'beforeQuery', $sql);
|
||||
|
||||
$res = $this->driver->query($sql) ? new DibiResult(clone $this->driver, $this->config) : NULL;
|
||||
if ($res = $this->driver->query($sql)) { // intentionally =
|
||||
$res = new DibiResult($res, $this->config);
|
||||
}
|
||||
|
||||
$time += microtime(TRUE);
|
||||
dibi::$elapsedTime = $time;
|
||||
|
@@ -37,9 +37,6 @@ abstract class DibiTable extends /*Nette::*/Object
|
||||
/** @var DibiConnection */
|
||||
private $connection;
|
||||
|
||||
/** @var array */
|
||||
private $options;
|
||||
|
||||
/** @var string table name */
|
||||
protected $name;
|
||||
|
||||
@@ -53,20 +50,16 @@ abstract class DibiTable extends /*Nette::*/Object
|
||||
protected $blankRow = array();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Table constructor.
|
||||
* @param array
|
||||
* @param DibiConnection
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(array $options = array())
|
||||
public function __construct(DibiConnection $connection = NULL)
|
||||
{
|
||||
$this->options = $options;
|
||||
|
||||
$this->connection = $connection === NULL ? dibi::getConnection() : $connection;
|
||||
$this->setup();
|
||||
|
||||
if ($this->connection === NULL) {
|
||||
$this->connection = dibi::getConnection();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -89,7 +89,7 @@ interface IDibiDriver
|
||||
* Internal: Executes the SQL query.
|
||||
*
|
||||
* @param string SQL statement.
|
||||
* @return bool have resultset?
|
||||
* @return IDibiDriver|NULL
|
||||
* @throws DibiDriverException
|
||||
*/
|
||||
function query($sql);
|
||||
|
Reference in New Issue
Block a user