1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-12 09:04:24 +02:00

- renamed configuration keys result:object, result:withtables and format:* to resultObject resp. resultWithTables (due compatibility with PHP 5.3 INI parser)

- updated class Object
This commit is contained in:
David Grudl
2008-08-25 18:55:50 +00:00
parent c438b72972
commit 119d5a1995
8 changed files with 104 additions and 45 deletions

View File

@@ -58,7 +58,7 @@ class DibiConnection extends /*Nette::*/Object
/**
* Creates object and (optionally) connects to a database.
*
* @param array|string|Nette::Collections::Hashtable connection parameters
* @param array|string|ArrayObject connection parameters
* @param string connection name
* @throws DibiException
*/
@@ -72,11 +72,11 @@ class DibiConnection extends /*Nette::*/Object
if (is_string($config)) {
parse_str($config, $config);
} elseif ($config instanceof /*Nette::Collections::*/Hashtable) {
} elseif ($config instanceof ArrayObject) {
$config = (array) $config;
} elseif (!is_array($config)) {
throw new InvalidArgumentException('Configuration must be array, string or Nette::Collections::Hashtable.');
throw new InvalidArgumentException('Configuration must be array, string or ArrayObject.');
}
if (!isset($config['driver'])) {
@@ -93,10 +93,20 @@ class DibiConnection extends /*Nette::*/Object
}
}
if (isset($config['result:withtables'])) {
$config['resultWithTables'] = $config['result:withtables'];
unset($config['result:withtables']);
}
if (isset($config['result:objects'])) {
$config['resultObjects'] = $config['result:objects'];
unset($config['result:objects']);
}
if (isset($config['resultObjects'])) {
// normalize
$val = $config['result:objects'];
$config['result:objects'] = is_string($val) && !is_numeric($val) ? $val : (bool) $val;
$val = $config['resultObjects'];
$config['resultObjects'] = is_string($val) && !is_numeric($val) ? $val : (bool) $val;
}
$config['name'] = $name;

View File

@@ -89,12 +89,12 @@ class DibiResult extends /*Nette::*/Object implements IDataSource
{
$this->driver = $driver;
if (!empty($config['result:withtables'])) {
if (!empty($config['resultWithTables'])) {
$this->setWithTables(TRUE);
}
if (isset($config['result:objects'])) {
$this->setObjects($config['result:objects']);
if (isset($config['resultObjects'])) {
$this->setObjects($config['resultObjects']);
}
}

View File

@@ -254,7 +254,7 @@ abstract class DibiTable extends /*Nette::*/Object
$row = $this->blankRow;
$row[$this->primary] = NULL;
if ($class = $this->connection->getConfig('result:objects')) {
if ($class = $this->connection->getConfig('resultObjects')) {
if ($class === TRUE) {
$row = (object) $row;
} else {