mirror of
https://github.com/dg/dibi.git
synced 2025-08-05 05:37:39 +02:00
- DibiResult::fetchAssoc() respects 'resultObject' configuration option
- DibiResult::dump() forces arrays - updated Nette::Object
This commit is contained in:
@@ -108,14 +108,22 @@ abstract class Object
|
|||||||
}
|
}
|
||||||
|
|
||||||
// event functionality
|
// event functionality
|
||||||
if (property_exists($class, $name) && preg_match('#^on[A-Z]#', $name)) {
|
if (preg_match('#^on[A-Z]#', $name)) {
|
||||||
$list = $this->$name;
|
$rp = new ReflectionProperty($class, $name);
|
||||||
if (is_array($list) || $list instanceof Traversable) {
|
if ($rp->isPublic() && !$rp->isStatic()) {
|
||||||
foreach ($list as $handler) {
|
$list = $this->$name;
|
||||||
call_user_func_array($handler, $args);
|
if (is_array($list) || $list instanceof Traversable) {
|
||||||
|
foreach ($list as $handler) {
|
||||||
|
/**/if (is_object($handler)) {
|
||||||
|
call_user_func_array(array($handler, '__invoke'), $args);
|
||||||
|
|
||||||
|
} else /**/{
|
||||||
|
call_user_func_array($handler, $args);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// extension methods
|
// extension methods
|
||||||
|
@@ -371,7 +371,7 @@ class DibiResult extends /*Nette::*/Object implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
// strip leading = and @
|
// strip leading = and @
|
||||||
$assoc[] = '='; // gap
|
$leaf = $this->objects ? $this->objects : '='; // gap
|
||||||
$last = count($assoc) - 1;
|
$last = count($assoc) - 1;
|
||||||
while ($assoc[$last] === '=' || $assoc[$last] === '@') {
|
while ($assoc[$last] === '=' || $assoc[$last] === '@') {
|
||||||
$leaf = $assoc[$last];
|
$leaf = $assoc[$last];
|
||||||
@@ -418,7 +418,13 @@ class DibiResult extends /*Nette::*/Object implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($x === NULL) { // build leaf
|
if ($x === NULL) { // build leaf
|
||||||
if ($leaf === '=') $x = $row; else $x = (object) $row;
|
if ($leaf === '=') {
|
||||||
|
$x = $row;
|
||||||
|
} elseif ($leaf === TRUE || $leaf === '@') {
|
||||||
|
$x = (object) $row;
|
||||||
|
} else {
|
||||||
|
$x = new $leaf($row);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} while ($row = $this->fetch(FALSE));
|
} while ($row = $this->fetch(FALSE));
|
||||||
@@ -588,9 +594,10 @@ class DibiResult extends /*Nette::*/Object implements IDataSource
|
|||||||
*/
|
*/
|
||||||
final public function dump()
|
final public function dump()
|
||||||
{
|
{
|
||||||
$none = TRUE;
|
$i = 0;
|
||||||
foreach ($this as $i => $row) {
|
$this->seek(0);
|
||||||
if ($none) {
|
while ($row = $this->fetch(FALSE)) {
|
||||||
|
if ($i === 0) {
|
||||||
echo "\n<table class=\"dump\">\n<thead>\n\t<tr>\n\t\t<th>#row</th>\n";
|
echo "\n<table class=\"dump\">\n<thead>\n\t<tr>\n\t\t<th>#row</th>\n";
|
||||||
|
|
||||||
foreach ($row as $col => $foo) {
|
foreach ($row as $col => $foo) {
|
||||||
@@ -598,7 +605,6 @@ class DibiResult extends /*Nette::*/Object implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo "\t</tr>\n</thead>\n<tbody>\n";
|
echo "\t</tr>\n</thead>\n<tbody>\n";
|
||||||
$none = FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "\t<tr>\n\t\t<th>", $i, "</th>\n";
|
echo "\t<tr>\n\t\t<th>", $i, "</th>\n";
|
||||||
@@ -607,9 +613,10 @@ class DibiResult extends /*Nette::*/Object implements IDataSource
|
|||||||
echo "\t\t<td>", htmlSpecialChars($col), "</td>\n";
|
echo "\t\t<td>", htmlSpecialChars($col), "</td>\n";
|
||||||
}
|
}
|
||||||
echo "\t</tr>\n";
|
echo "\t</tr>\n";
|
||||||
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($none) {
|
if ($i === 0) {
|
||||||
echo '<p><em>empty result set</em></p>';
|
echo '<p><em>empty result set</em></p>';
|
||||||
} else {
|
} else {
|
||||||
echo "</tbody>\n</table>\n";
|
echo "</tbody>\n</table>\n";
|
||||||
|
Reference in New Issue
Block a user