コード例 #1
0
ファイル: loader.php プロジェクト: svoby/graweb2010
function dump($var)
{
    foreach (func_get_args() as $arg) {
        NDebug::dump($arg);
    }
    return $var;
}
コード例 #2
0
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">

<h1>Using Extension Methods | dibi</h1>

<?php 
require_once 'Nette/Debug.php';
require_once '../dibi/dibi.php';
dibi::connect(array('driver' => 'sqlite', 'database' => 'data/sample.sdb'));
// using the "prototype" to add custom method to class DibiResult
function DibiResult_prototype_fetchShuffle(DibiResult $obj)
{
    $all = $obj->fetchAll();
    shuffle($all);
    return $all;
}
// fetch complete result set shuffled
$res = dibi::query('SELECT * FROM [customers]');
$all = $res->fetchShuffle();
NDebug::dump($all);
コード例 #3
0
ファイル: nette.php プロジェクト: kacer/FakturoidPairing
    function renderPanel()
    {
        ?>
<style>#nette-debug-RoutingDebugger table{font:9pt/1.5 Consolas,monospace}#nette-debug-RoutingDebugger .yes td{color:green}#nette-debug-RoutingDebugger .may td{color:#67F}#nette-debug-RoutingDebugger pre,#nette-debug-RoutingDebugger code{display:inline}</style>

<h1>
<?php 
        if (empty($this->request)) {
            ?>
	no route
<?php 
        } else {
            ?>
	<?php 
            echo $this->request->getPresenterName() . ':' . (isset($this->request->params[NPresenter::ACTION_KEY]) ? $this->request->params[NPresenter::ACTION_KEY] : NPresenter::$defaultAction);
        }
        ?>
</h1>

<?php 
        if (!empty($this->request)) {
            ?>
	<?php 
            $params = $this->request->getParams();
            ?>
	<?php 
            if (empty($params)) {
                ?>
		<p>No parameters.</p>

	<?php 
            } else {
                ?>
		<table>
		<thead>
		<tr>
			<th>Parameter</th>
			<th>Value</th>
		</tr>
		</thead>
		<tbody>
		<?php 
                unset($params[NPresenter::ACTION_KEY]);
                ?>
		<?php 
                foreach ($params as $key => $value) {
                    ?>
		<tr>
			<td><code><?php 
                    echo htmlSpecialChars($key);
                    ?>
</code></td>
			<td><?php 
                    if (is_string($value)) {
                        ?>
<code><?php 
                        echo htmlSpecialChars($value);
                        ?>
</code><?php 
                    } else {
                        echo NDebug::dump($value, TRUE);
                    }
                    ?>
</td>
		</tr>
		<?php 
                }
                ?>
		</tbody>
		</table>
	<?php 
            }
        }
        ?>

<h2>Routers</h2>

<?php 
        if (empty($this->routers)) {
            ?>
	<p>No routers defined.</p>

<?php 
        } else {
            ?>
	<div class="nette-inner">
	<table>
	<thead>
	<tr>
		<th>Matched?</th>
		<th>Class</th>
		<th>Mask</th>
		<th>Defaults</th>
		<th>Request</th>
	</tr>
	</thead>

	<tbody>
	<?php 
            foreach ($this->routers as $router) {
                ?>
	<tr class="<?php 
                echo $router['matched'];
                ?>
">
		<td><?php 
                echo $router['matched'];
                ?>
</td>

		<td><code><?php 
                echo htmlSpecialChars($router['class']);
                ?>
</code></td>

		<td><code><strong><?php 
                echo htmlSpecialChars($router['mask']);
                ?>
</strong></code></td>

		<td><code>
		<?php 
                foreach ($router['defaults'] as $key => $value) {
                    ?>
			<?php 
                    echo htmlSpecialChars($key), "&nbsp;=&nbsp;", is_string($value) ? htmlSpecialChars($value) : str_replace("\n</pre", '</pre', NDebug::dump($value, TRUE));
                    ?>
<br />
		<?php 
                }
                ?>
		</code></td>

		<td><?php 
                if ($router['request']) {
                    ?>
<code>
		<?php 
                    $params = $router['request']->getParams();
                    ?>
		<strong><?php 
                    echo htmlSpecialChars($router['request']->getPresenterName() . ':' . (isset($params[NPresenter::ACTION_KEY]) ? $params[NPresenter::ACTION_KEY] : NPresenter::$defaultAction));
                    ?>
</strong><br />
		<?php 
                    unset($params[NPresenter::ACTION_KEY]);
                    ?>
		<?php 
                    foreach ($params as $key => $value) {
                        ?>
			<?php 
                        echo htmlSpecialChars($key), "&nbsp;=&nbsp;", is_string($value) ? htmlSpecialChars($value) : str_replace("\n</pre", '</pre', NDebug::dump($value, TRUE));
                        ?>
<br />
		<?php 
                    }
                    ?>
		</code><?php 
                }
                ?>
</td>
	</tr>
	<?php 
            }
            ?>
	</tbody>
	</table>
	</div>
<?php 
        }
    }
コード例 #4
0
// key
NDebug::dump($assoc);
// fetch complete result set like pairs key => value
echo "<h2>fetchPairs('product_id', 'title')</h2>\n";
$pairs = $res->fetchPairs('product_id', 'title');
NDebug::dump($pairs);
// fetch row by row
echo "<h2>using foreach</h2>\n";
foreach ($res as $n => $row) {
    NDebug::dump($row);
}
// more complex association array
$res = dibi::query('
	SELECT *
	FROM products
	INNER JOIN orders USING (product_id)
	INNER JOIN customers USING (customer_id)
');
echo "<h2>fetchAssoc('customers.name|products.title')</h2>\n";
$assoc = $res->fetchAssoc('customers.name|products.title');
// key
NDebug::dump($assoc);
echo "<h2>fetchAssoc('customers.name[]products.title')</h2>\n";
$assoc = $res->fetchAssoc('customers.name[]products.title');
// key
NDebug::dump($assoc);
echo "<h2>fetchAssoc('customers.name->products.title')</h2>\n";
$assoc = $res->fetchAssoc('customers.name->products.title');
// key
NDebug::dump($assoc);
コード例 #5
0
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">

<h1>Result Set Data Types  | dibi</h1>

<?php 
require_once 'Nette/Debug.php';
require_once '../dibi/dibi.php';
date_default_timezone_set('Europe/Prague');
dibi::connect(array('driver' => 'sqlite', 'database' => 'data/sample.sdb'));
// using manual hints
$res = dibi::query('SELECT * FROM [customers]');
$res->setType('customer_id', Dibi::INTEGER)->setType('added', Dibi::DATETIME, 'H:i j.n.Y');
NDebug::dump($res->fetch());
// outputs:
// object(DibiRow)#3 (3) {
//     customer_id => int(1)
//     name =>  string(11) "Dave Lister"
//     added =>  object(DateTime53) {}
// }
// using auto-detection (works well with MySQL or other strictly typed databases)
$res = dibi::query('SELECT * FROM [customers]');
$res->detectTypes();
NDebug::dump($res->fetch());
// outputs:
// object(DibiRow)#3 (3) {
//     customer_id => int(1)
//     name =>  string(11) "Dave Lister"
//     added =>  string(15) "17:20 11.3.2007"
// }
コード例 #6
0
ファイル: CssUrlsFilter.php プロジェクト: oaki/demoshop
 function m($matches, $file, $sourcePath)
 {
     //		NDebug::dump($file);
     NDebug::dump($matches);
     //		NDebug::dump($sourcePath);
     return "url('" . CssUrlsFilter::absolutizeUrl($matches[2], $matches[1], $file, $sourcePath) . "')";
 }