1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-18 03:41:30 +02:00

- added configuration option 'resultClass'

- updated class Object
This commit is contained in:
David Grudl
2008-08-28 02:02:21 +00:00
parent 119d5a1995
commit 360f8799cf
3 changed files with 38 additions and 17 deletions

View File

@@ -53,6 +53,12 @@ class DibiConnection extends /*Nette::*/Object
*/
private $inTxn = FALSE;
/**
* Result set encapsulation.
* @var string
*/
private $resultClass = 'DibiResult';
/**
@@ -103,12 +109,18 @@ class DibiConnection extends /*Nette::*/Object
unset($config['result:objects']);
}
if (isset($config['resultObjects'])) {
// normalize
if (isset($config['resultObjects'])) { // normalize
$val = $config['resultObjects'];
$config['resultObjects'] = is_string($val) && !is_numeric($val) ? $val : (bool) $val;
}
if (isset($config['resultClass'])) {
if (strcasecmp($config['resultClass'], 'DibiResult') && !is_subclass_of($config['resultClass'], 'DibiResult')) {
throw new InvalidArgumentException("Class '$config[resultClass]' is not DibiResult descendant.");
}
$this->resultClass = $config['resultClass'];
}
$config['name'] = $name;
$this->config = $config;
$this->driver = new $class;
@@ -294,7 +306,7 @@ class DibiConnection extends /*Nette::*/Object
dibi::notify($this, 'beforeQuery', $sql);
if ($res = $this->driver->query($sql)) { // intentionally =
$res = new DibiResult($res, $this->config);
$res = new $this->resultClass($res, $this->config);
}
$time += microtime(TRUE);