示例#1
0
register_shutdown_function(function () {
    sqlp('close');
    sqlO('close');
});
#print_r($_ENV);
$_ENV['titre'] = 'mysqli object && flat php prepared statements, transactions';
require_once '../header.c.php';
echo '<pre>';
$x = sqlO('select id,id_season from articles order by id desc limit 1');
if ($x['#']) {
    #has errors
    if ($x['0']['error'] == 'No database selected') {
        print_r($x);
        die;
    }
    $fun->r302('sql6-cache.php?r=mysqli.php#migrations required');
}
/** creates required database && tables **/
print_r(['sqlTransaction1:select'] + compact('x'));
#ERRORS:$x['#"] && $x[$index][0]=is_numeric(ERRORLINE);
$x = sqlp('SELECT id,title,id_season from articles order by id desc limit ?', [1]);
print_r(['sqlp2'] + compact('x'));
$x = sqlO(['select id,id_season from articles order by id desc limit ?', 'insert into test.articles (title,id_season)values(?,?)'], [[1], ['--new2', 26]]);
print_r(['sqlTransaction2:select'] + compact('x'));
#fails & fails select as well !
$x = sqlO('insert into articles (title,id_season)values(?,?)', [['--new1', 24], ['--new2', 25], ['fail', 26]]);
print_r(['sqlTransaction1'] + compact('x'));
#fails !
$x = sqlO('insert into articles (title,id_season)values(?,?)', [['--new1', 24], ['--ok', 25]]);
print_r(['sqlTransaction3'] + compact('x'));
#ok
示例#2
0
<?php

$fun = new f();
register_shutdown_function(function () {
    global $fun;
    if ($_GET['r']) {
        $fun->r302($_GET['r'] . '#post required migration');
    }
});
#print_r($_ENV);
$_ENV['titre'] = 'sql6-cached';
require_once '../header.c.php';
echo '<pre>';
#new fun;#ok with autoloader -- fine :)
new sql6();
#$con=[$host,$user,$pass];
$single = 1;
$cd = TMP . 'sqlcache/';
$con = $sqlconn;
$iP = ['databases'];
$pile = 'Database';
/*using $iP caches the results and index them under those names for cache invalidations*/
#sql6(['pl'=>['databases']]);die;
$sep = '§§!';
$migrations = ['0.0.1.createdb.test' => ['title' => "1st migration : creates database test && table products", 'precheck' => function () {
    global $con;
    $sql = 'show databases';
    $iP = ['databases'];
    $pile = 'Database';
    $x = sql6(compact('con', 'iP', 'sql', 'pile'));
    #,'pile'=>'Database'