1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-07 06:36:44 +02:00

fixed compatibility with Nette::Config

This commit is contained in:
David Grudl
2008-05-13 13:02:26 +00:00
parent 40e9f313c3
commit b27b0193f1
3 changed files with 18 additions and 12 deletions

View File

@@ -164,7 +164,7 @@ class dibi
/** /**
* Creates a new DibiConnection object and connects it to specified database. * Creates a new DibiConnection object and connects it to specified database.
* *
* @param array|string|Nette::Collections::IMap connection parameters * @param array|string|Nette::Collections::Hashtable connection parameters
* @param string connection name * @param string connection name
* @return DibiConnection * @return DibiConnection
* @throws DibiException * @throws DibiException

View File

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

View File

@@ -229,7 +229,7 @@ class DibiResult extends /*Nette::*/Object implements IDataSource
*/ */
public function setObjects($type) public function setObjects($type)
{ {
$this->objects = is_string($type) ? $type : (bool) $type; $this->objects = $type;
} }