mirror of
https://github.com/dg/dibi.git
synced 2025-08-06 06:07:39 +02:00
introduced new class constants
This commit is contained in:
@@ -111,6 +111,13 @@ class dibi
|
|||||||
VERSION = '0.9',
|
VERSION = '0.9',
|
||||||
REVISION = '$WCREV$ released on $WCDATE$';
|
REVISION = '$WCREV$ released on $WCDATE$';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration options
|
||||||
|
*/
|
||||||
|
const
|
||||||
|
RESULT_WITH_TABLES = 'resultWithTables',
|
||||||
|
RESULT_OBJECTS = 'resultObjects',
|
||||||
|
RESULT_CLASS = 'resultClass';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connection registry storage for DibiConnection objects.
|
* Connection registry storage for DibiConnection objects.
|
||||||
|
@@ -100,25 +100,25 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isset($config['result:withtables'])) {
|
if (isset($config['result:withtables'])) {
|
||||||
$config['resultWithTables'] = $config['result:withtables'];
|
$config[dibi::RESULT_WITH_TABLES] = $config['result:withtables'];
|
||||||
unset($config['result:withtables']);
|
unset($config['result:withtables']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($config['result:objects'])) {
|
if (isset($config['result:objects'])) {
|
||||||
$config['resultObjects'] = $config['result:objects'];
|
$config[dibi::RESULT_OBJECTS] = $config['result:objects'];
|
||||||
unset($config['result:objects']);
|
unset($config['result:objects']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($config['resultObjects'])) { // normalize
|
if (isset($config[dibi::RESULT_OBJECTS])) { // normalize
|
||||||
$val = $config['resultObjects'];
|
$val = $config[dibi::RESULT_OBJECTS];
|
||||||
$config['resultObjects'] = is_string($val) && !is_numeric($val) ? $val : (bool) $val;
|
$config[dibi::RESULT_OBJECTS] = is_string($val) && !is_numeric($val) ? $val : (bool) $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($config['resultClass'])) {
|
if (isset($config[dibi::RESULT_CLASS])) {
|
||||||
if (strcasecmp($config['resultClass'], 'DibiResult') && !is_subclass_of($config['resultClass'], 'DibiResult')) {
|
if (strcasecmp($config[dibi::RESULT_CLASS], 'DibiResult') && !is_subclass_of($config[dibi::RESULT_CLASS], 'DibiResult')) {
|
||||||
throw new InvalidArgumentException("Class '$config[resultClass]' is not DibiResult descendant.");
|
throw new InvalidArgumentException("Class '$config[resultClass]' is not DibiResult descendant.");
|
||||||
}
|
}
|
||||||
$this->resultClass = $config['resultClass'];
|
$this->resultClass = $config[dibi::RESULT_CLASS];
|
||||||
}
|
}
|
||||||
|
|
||||||
$config['name'] = $name;
|
$config['name'] = $name;
|
||||||
|
@@ -89,12 +89,12 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
{
|
{
|
||||||
$this->driver = $driver;
|
$this->driver = $driver;
|
||||||
|
|
||||||
if (!empty($config['resultWithTables'])) {
|
if (!empty($config[dibi::RESULT_WITH_TABLES])) {
|
||||||
$this->setWithTables(TRUE);
|
$this->setWithTables(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($config['resultObjects'])) {
|
if (isset($config[dibi::RESULT_OBJECTS])) {
|
||||||
$this->setObjects($config['resultObjects']);
|
$this->setObjects($config[dibi::RESULT_OBJECTS]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -297,7 +297,7 @@ abstract class DibiTable extends DibiObject
|
|||||||
$row = $this->blankRow;
|
$row = $this->blankRow;
|
||||||
$row[$this->primary] = NULL;
|
$row[$this->primary] = NULL;
|
||||||
|
|
||||||
if ($class = $this->connection->getConfig('resultObjects')) {
|
if ($class = $this->connection->getConfig(dibi::RESULT_OBJECTS)) {
|
||||||
if ($class === TRUE) {
|
if ($class === TRUE) {
|
||||||
$row = (object) $row;
|
$row = (object) $row;
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user