Beispiel #1
0
<?php

//TODO: solve the problem with diacritic marks
# loader Nix libraries
require_once '../../src/Nix/loader.php';
use Nix\Debugging\Debugger, Nix\Database\Db, Nix\Database\Table;
Debugger::init(true);
Debugger::setLogPath(__DIR__ . '/../temp/');
Db::connect(array('database' => 'nix_examples'));
$class = Table::init('albums');
$albums = new $class();
$form = $albums->getForm();
$form->renderer->javascript = false;
if ($form->isSubmit() && $form->isValid()) {
    dump($form->data);
}
echo $form->renderer->render();
Beispiel #2
0
<?php

# loader Nix libraries
require_once '../../src/Nix/loader.php';
use Nix\Debugging\Debugger, Nix\Database\Db;
Debugger::init(true);
Debugger::setLogPath(__DIR__ . '/../temp/');
Db::connect(array('database' => 'nix_examples'));
echo '<h2>escaping</h2>';
$a = array('test%r' => 'Now()', 'tests%s' => 'SuperTest\'', 'tsadst' => true);
dump(db::getConnection()->escapeArray($a));
echo '<h2>fetch field</h2>';
dump(Db::fetchField("select [name] from [albums] order by RAND() limit 1"));
echo '<h2>fetch all</h2>';
dump(Db::fetchAll("select * from [albums] order by [name] limit 3"));
echo '<h2>fetch pairs</h2>';
dump(Db::fetchPairs("select [id], [name] from [albums] order by RAND() limit 10"));
echo '<h2>fetch pairs</h2>';
dump(Db::fetchPairs("select [name] from [albums] order by RAND() limit 10"));
Beispiel #3
0
    echo "<li>" . $entry->artists->name;
    if (!empty($entry->albums)) {
        echo "<ul>";
        foreach ($entry->albums as $album) {
            echo "<li>" . $album->name . "</li>";
        }
        echo "</ul>";
    }
    echo "</li>";
}
echo "</ul>";
echo "<hr />";
# ==============================================================================
$query = Db::prepare('
select * from [artists]
left join [albums] on [albums.artist_id] = [artists.id]
left join [partners] on [artists.partner_id] = [partners.id]
');
$query->setAssociation('artists', 'albums');
$query->execute();
echo "<ul>";
foreach ($query->fetchAll() as $entry) {
    echo "<li>" . $entry->artists->name;
    if (!empty($entry->partners->id)) {
        echo "<br> Partner: " . $entry->partners->name;
    }
    if (!empty($entry->albums)) {
        echo "<br />Albums: <ul>";
        foreach ($entry->albums as $album) {
            echo "<li>" . $album->name . "</li>";
        }