1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-06 06:07:39 +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.
*
* @param array|string|Nette::Collections::IMap connection parameters
* @param array|string|Nette::Collections::Hashtable connection parameters
* @param string connection name
* @return DibiConnection
* @throws DibiException

View File

@@ -58,7 +58,7 @@ class DibiConnection extends /*Nette::*/Object
/**
* 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
* @throws DibiException
*/
@@ -68,11 +68,11 @@ class DibiConnection extends /*Nette::*/Object
if (is_string($config)) {
parse_str($config, $config);
} elseif ($config instanceof /*Nette::Collections::*/IMap) {
$config = $config->toArray();
} elseif ($config instanceof /*Nette::Collections::*/Hashtable) {
$config = (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'])) {
@@ -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;
$this->config = $config;
$this->driver = new $class;

View File

@@ -229,7 +229,7 @@ class DibiResult extends /*Nette::*/Object implements IDataSource
*/
public function setObjects($type)
{
$this->objects = is_string($type) ? $type : (bool) $type;
$this->objects = $type;
}
@@ -281,12 +281,12 @@ class DibiResult extends /*Nette::*/Object implements IDataSource
}
if ($objects) {
if ($objects === TRUE) {
$row = (object) $row;
} else {
$row = new $objects($row);
}
}
if ($objects === TRUE) {
$row = (object) $row;
} else {
$row = new $objects($row);
}
}
return $row;
}