GlisWeb framework
_postgresql.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['postgresql']['connections'], true );
20 
21  // pulizia della tabella
22  postgresqlPreparedQuery( $cf['postgresql']['connection'], 'TRUNCATE test' );
23 
24  // dati di test
25  $tempo = time();
26  $nome = 'prova' . $tempo;
27 
28  // inserimento di test
29  postgresqlQuery( $cf['postgresql']['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( postgresqlQuery( $cf['postgresql']['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  postgresqlPreparedQuery( $cf['postgresql']['connection'], 'INSERT INTO test ( nome, timestamp ) VALUES ( $1, $2 )', array(
41  $nome,
42  $tempo
43  ));
44 
45  // recupero dati di test
46  $tx .= 'INSERT e SELECT preparata (2 elementi): ' . PHP_EOL;
47  $tx .= print_r( postgresqlPreparedQuery( $cf['postgresql']['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( postgresqlCachedQuery( $cf['memcache']['connection'], $cf['postgresql']['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  postgresqlPreparedQuery( $cf['postgresql']['connection'], 'INSERT INTO test ( nome, timestamp ) VALUES ( $1, $2 )', array(
59  $nome,
60  $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( postgresqlCachedQuery( $cf['memcache']['connection'], $cf['postgresql']['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( postgresqlPreparedQuery( $cf['postgresql']['connection'], 'SELECT * FROM test' ), true );
71 
72  // pulizia della tabella
73  postgresqlPreparedQuery( $cf['postgresql']['connection'], 'TRUNCATE test' );
74 
75  // output
76  build( $tx );
77 
78 ?>
$tx
Definition: _postgresql.php:32
$cf['ricerca']['template']
Definition: _030.common.php:7
$nome
Definition: _postgresql.php:26
postgresqlQuery( $c, $q, $p=false, &$e=array())
postgresqlCachedQuery( $m, $c, $q, $p=false, $t=MEMCACHE_DEFAULT_TTL, &$e=array())
postgresqlPreparedQuery( $c, $q, $p=array(), &$e=array())
$tempo
Definition: _postgresql.php:25
build( $content, $type=MIME_TEXT_PLAIN, $encoding=ENCODING_UTF8, $headers=array())