From b27b0193f16943ef1496e7c18c611414c46b82f8 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 13 May 2008 13:02:26 +0000 Subject: [PATCH] fixed compatibility with Nette::Config --- dibi/dibi.php | 2 +- dibi/libs/DibiConnection.php | 14 ++++++++++---- dibi/libs/DibiResult.php | 14 +++++++------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/dibi/dibi.php b/dibi/dibi.php index bbe0089e..aa1043de 100644 --- a/dibi/dibi.php +++ b/dibi/dibi.php @@ -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 diff --git a/dibi/libs/DibiConnection.php b/dibi/libs/DibiConnection.php index 3df20f55..8c2d86dc 100644 --- a/dibi/libs/DibiConnection.php +++ b/dibi/libs/DibiConnection.php @@ -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; diff --git a/dibi/libs/DibiResult.php b/dibi/libs/DibiResult.php index 57b9d85a..002f4b0d 100644 --- a/dibi/libs/DibiResult.php +++ b/dibi/libs/DibiResult.php @@ -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; }