コード例 #1
0
ファイル: db.php プロジェクト: literat/nix-examples
<?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"));
コード例 #2
0
ファイル: index.php プロジェクト: literat/nix-examples
<?php

# nacteme knihovnu
ob_start();
# loader Nix libraries
require_once '../../src/Nix/loader.php';
use Nix\Templating\Template, Nix\Debugging\Debugger, Nix\Utils\Paginator, Nix\Templating\Helpers\HtmlHelper, Nix\Http\Http;
Debugger::setLogPath(__DIR__ . '/../temp/');
Debugger::init(TRUE);
/**
 * Processes the framework url
 * 
 * @param string $url url
 * @param array $args rewrite args
 * @param array|false $params rewrite params
 * @return string
 */
function frameworkUrl($url, $args = array(), $params = false)
{
    if (empty($url)) {
        $url = Http::$request->request;
    } else {
        $url = preg_replace('#\\<\\:([a-z0-9]+)\\>#ie', "isset(\$args['']) ? \$args[''] : ''", $url);
    }
    if ($params !== false) {
        $p = array();
        $params = array_merge($_GET, (array) $params);
        foreach ($params as $name => $value) {
            if ($value == null) {
                continue;
            }