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:
@@ -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
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user