GlisWeb framework
_mysql.php
Vai alla documentazione di questo file.
1 <?php
2 
15  // inclusione del framework
16  require '../../../_src/_config.php';
17 
18  // stato connessioni
19  // $tx = print_r( $cf['mysql']['connections'], true );
20 
21  // pulizia della tabella
22  mysqlPreparedQuery( $cf['mysql']['connection'], 'TRUNCATE test' );
23 
24  // dati di test
25  $tempo = time();
26  $nome = 'prova' . $tempo;
27 
28  // inserimento di test
29  mysqlQuery( $cf['mysql']['connection'], "INSERT INTO test ( nome, timestamp ) VALUES ( '$nome', '$tempo' )" );
30 
31  // recupero dati di test
32  $tx = 'INSERT e SELECT standard (1 elemento): ' . PHP_EOL;
33  $tx .= print_r( mysqlQuery( $cf['mysql']['connection'], 'SELECT * FROM test' ), true );
34 
35  // dati di test
36  $tempo = time() + 1;
37  $nome = 'prova' . $tempo;
38 
39  // inserimento preparato di test
40  mysqlQuery( $cf['mysql']['connection'], 'INSERT INTO test ( nome, timestamp ) VALUES ( ?, ? )', array(
41  array( 's' => $nome ),
42  array( 'i' => $tempo )
43  ));
44 
45  // recupero dati di test
46  $tx .= 'INSERT e SELECT preparata (2 elementi): ' . PHP_EOL;
47  $tx .= print_r( mysqlPreparedQuery( $cf['mysql']['connection'], 'SELECT * FROM test' ), true );
48 
49  // test della cache (uso false per forzare il refresh)
50  $tx .= 'SELECT in cache pre INSERT (2 elementi): ' . PHP_EOL;
51  $tx .= print_r( mysqlCachedQuery( $cf['memcache']['connection'], $cf['mysql']['connection'], 'SELECT * FROM test', false, false ), true );
52 
53  // dati di test
54  $tempo = time() + 2;
55  $nome = 'prova' . $tempo;
56 
57  // inserimento preparato di test
58  mysqlQuery( $cf['mysql']['connection'], 'INSERT INTO test ( nome, timestamp ) VALUES ( ?, ? )', array(
59  array( 's' => $nome ),
60  array( 'i' => $tempo )
61  ));
62 
63  // test della cache
64  $tx .= 'INSERT preparata per testare la cache' . PHP_EOL;
65  $tx .= 'SELECT in cache post INSERT (2 elementi invece di 3): ' . PHP_EOL;
66  $tx .= print_r( mysqlCachedQuery( $cf['memcache']['connection'], $cf['mysql']['connection'], 'SELECT * FROM test' ), true );
67 
68  // recupero dati di test
69  $tx .= 'SELECT standard post INSERT (3 elementi): ' . PHP_EOL;
70  $tx .= print_r( mysqlQuery( $cf['mysql']['connection'], 'SELECT * FROM test' ), true );
71 
72  // pulizia della tabella
73  mysqlPreparedQuery( $cf['mysql']['connection'], 'TRUNCATE test' );
74 
75  // output
76  build( $tx );
77 
78 ?>
mysqlQuery( $c, $q, $p=false, &$e=array())
$cf['ricerca']['template']
Definition: _030.common.php:7
$nome
Definition: _mysql.php:26
mysqlPreparedQuery( $c, $q, $params=array(), &$e=array())
mysqlCachedQuery( $m, $c, $q, $p=false, $t=MEMCACHE_DEFAULT_TTL, &$e=array())
$tempo
Definition: _mysql.php:25
$tx
Definition: _mysql.php:32
build( $content, $type=MIME_TEXT_PLAIN, $encoding=ENCODING_UTF8, $headers=array())