mirror of
https://github.com/dg/dibi.git
synced 2025-08-07 14:46:50 +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.
|
* 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
|
||||||
|
@@ -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;
|
||||||
|
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -281,12 +281,12 @@ class DibiResult extends /*Nette::*/Object implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($objects) {
|
if ($objects) {
|
||||||
if ($objects === TRUE) {
|
if ($objects === TRUE) {
|
||||||
$row = (object) $row;
|
$row = (object) $row;
|
||||||
} else {
|
} else {
|
||||||
$row = new $objects($row);
|
$row = new $objects($row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user