Esempio n. 1
0
function mdump($var, $tag = null)
{
    if ($tag) {
        $tag = '[' . $tag . ']';
    }
    $msg = $tag . Tracy\Dumper::toText($var, array('truncate' => 400));
    Maestro\Manager::dump($msg);
}
Esempio n. 2
0
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">

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

<?php 
if (@(!(include __DIR__ . '/../vendor/autoload.php'))) {
    die('Install dependencies using `composer install --dev`');
}
Tracy\Debugger::enable();
dibi::connect(array('driver' => 'sqlite3', 'database' => 'data/sample.s3db'));
// using the "prototype" to add custom method to class DibiResult
DibiResult::extensionMethod('fetchShuffle', function (DibiResult $obj) {
    $all = $obj->fetchAll();
    shuffle($all);
    return $all;
});
// fetch complete result set shuffled
$res = dibi::query('SELECT * FROM [customers]');
$all = $res->fetchShuffle();
Tracy\Dumper::dump($all);
Esempio n. 3
0
            <?php 
foreach ($logs as $log) {
    ?>
                <tr>
                    <th>
                        <span class="tracy-dump-object"><?php 
    echo array_get($log, 'firing');
    ?>
</span><br />
                        <?php 
    echo array_get($log, 'editorLink');
    ?>
<br />
                        <span class="tracy-dump-string"><?php 
    echo round(array_get($log, 'execTime', 0) * 100, 2);
    ?>
 ms</span>
                    </th>
                    <td>
                        <?php 
    echo Tracy\Dumper::toHtml(array_get($log, 'params'), array_merge((array) $dumpOption, [Tracy\Dumper::TRUNCATE => 50, Tracy\Dumper::COLLAPSE => true]));
    ?>
                    </td>
                </tr>
            <?php 
}
?>
        </tbody>
    </table>
</div>
    /**
     * @return bool
     */
    public static function validateDate(Nette\Forms\IControl $control)
    {
        return is_numeric($control->day) && is_numeric($control->month) && is_numeric($control->year) && checkdate($control->month, $control->day, $control->year);
    }
}
Tracy\Debugger::enable();
$form = new Form();
$form['date'] = new DateInput('Date:');
$form['date']->setDefaultValue(new DateTime());
$form->addSubmit('submit', 'Send');
if ($form->isSuccess()) {
    echo '<h2>Form was submitted and successfully validated</h2>';
    Tracy\Dumper::dump($form->getValues());
    exit;
}
?>
<!DOCTYPE html>
<meta charset="utf-8">
<title>Nette Forms custom control example</title>
<link rel="stylesheet" media="screen" href="assets/style.css" />

<h1>Nette Forms custom control example</h1>

<?php 
echo $form;
?>

<footer><a href="https://doc.nette.org/en/forms">see documentation</a></footer>
Esempio n. 5
0
    ?>
        <p>No identity</p>
    <?php 
} else {
    ?>
        <table>
            <tbody>
                <?php 
    foreach ($user as $key => $value) {
        ?>
                    <tr>
                        <th><?php 
        echo $key;
        ?>
</th>
                        <td>
                            <?php 
        echo Tracy\Dumper::toHtml($value, [Tracy\Dumper::LIVE => true]);
        ?>
                        </td>
                    </tr>
                <?php 
    }
    ?>
            </tbody>
        </table>
    <?php 
}
?>
</div>
Esempio n. 6
0
                        <th><?php 
        echo $key;
        ?>
</th>
                        <td>
                            <?php 
        if (is_string($value) === true) {
            ?>
                                <?php 
            echo $value;
            ?>
                            <?php 
        } else {
            ?>
                                <?php 
            echo Tracy\Dumper::toHtml($value, $dumpOption);
            ?>
                            <?php 
        }
        ?>
                        </td>
                    </tr>
                <?php 
    }
    ?>
            </tbody>
        </table>
    <?php 
}
?>
</div>
Esempio n. 7
0
$res = dibi::query('SELECT * FROM products');
$pairs = $res->fetchPairs('product_id', 'title');
Tracy\Dumper::dump($pairs);
// fetch row by row
echo "<h2>using foreach</h2>\n";
$res = dibi::query('SELECT * FROM products');
foreach ($res as $n => $row) {
    Tracy\Dumper::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('name|title')</h2>\n";
$assoc = $res->fetchAssoc('name|title');
// key
Tracy\Dumper::dump($assoc);
echo "<h2>fetchAssoc('name[]title')</h2>\n";
$res = dibi::query('SELECT * FROM products INNER JOIN orders USING (product_id) INNER JOIN customers USING (customer_id)');
$assoc = $res->fetchAssoc('name[]title');
// key
Tracy\Dumper::dump($assoc);
echo "<h2>fetchAssoc('name->title')</h2>\n";
$res = dibi::query('SELECT * FROM products INNER JOIN orders USING (product_id) INNER JOIN customers USING (customer_id)');
$assoc = $res->fetchAssoc('name->title');
// key
Tracy\Dumper::dump($assoc);
Esempio n. 8
0
        </tr>
        <?php 
foreach ($events as $key => $value) {
    ?>
            <tr>
                <th>
                    <span class="tracy-dump-object"><?php 
    echo array_get($value, 'firing');
    ?>
</span><br />
                    <?php 
    echo array_get($value, 'editorLink');
    ?>
<br />
                    <?php 
    echo round(array_get($value, 'execTime', 0) * 100, 2);
    ?>
 ms
                </th>
                <td>
                    <?php 
    echo Tracy\Dumper::toHtml(array_get($value, 'params'), [Tracy\Dumper::LIVE => true, Tracy\Dumper::TRUNCATE => 50, Tracy\Dumper::COLLAPSE => true]);
    ?>
                </td>
            </tr>
        <?php 
}
?>
    </table>
</div>
Esempio n. 9
0
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">

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

<?php 
use Dibi\Type;
if (@(!(include __DIR__ . '/../vendor/autoload.php'))) {
    die('Install dependencies using `composer install --dev`');
}
Tracy\Debugger::enable();
date_default_timezone_set('Europe/Prague');
dibi::connect(['driver' => 'sqlite3', 'database' => 'data/sample.s3db']);
// using manual hints
$res = dibi::query('SELECT * FROM [customers]');
$res->setType('customer_id', Type::INTEGER)->setType('added', Type::DATETIME)->setFormat(Type::DATETIME, 'Y-m-d H:i:s');
Tracy\Dumper::dump($res->fetch());
// outputs:
// Dibi\Row(3) {
//    customer_id => 1
//    name => "Dave Lister" (11)
//    added => "2007-03-11 17:20:03" (19)
// using auto-detection (works well with MySQL or other strictly typed databases)
$res = dibi::query('SELECT * FROM [customers]');
Tracy\Dumper::dump($res->fetch());
// outputs:
// Dibi\Row(3) {
//    customer_id => 1
//    name => "Dave Lister" (11)
//    added => "2007-03-11 17:20:03" (19)
Esempio n. 10
0
function dump($var)
{
    Tracy\Dumper::dump($var, [Tracy\Dumper::TRUNCATE => 1024, Tracy\Dumper::COLLAPSE => 30, Tracy\Dumper::COLLAPSE_COUNT => 15, Tracy\Dumper::DEPTH => 6]);
    return $var;
}
Esempio n. 11
0
            <th>
                name
            </th>
            <th>
                data
            </th>
        </tr>
        <?php 
foreach ($views as $view) {
    ?>
            <tr>
                <td>
                    <?php 
    echo $view['name'];
    ?>
                    <?php 
    echo $view['path'];
    ?>
                </td>
                <td>
                    <?php 
    echo Tracy\Dumper::toHtml($view['data'], [Tracy\Dumper::LIVE => true]);
    ?>
                </td>
            </tr>
        <?php 
}
?>
    </table>
</div>