GlisWeb framework
_mssql.utils.php
Vai alla documentazione di questo file.
1 <?php
2 
10  function mssqlCachedQuery( $m, $c, $q, $p = false, $t = MEMCACHE_DEFAULT_TTL, &$e = array() ) {
11 
12  // compongo la chiave per la query $q
13  $key = md5( $q );
14 
15  // cerco il risultato in cache
16  $r = memcacheRead( $m, $key );
17 
18  // se il risultato e' presente in cache
19  if( $r ) {
20 
21  // il dato presente in cache e' corretto e aggiornato
22  $rsArray = $r;
23 
24  // debug
25  // debugVar( $r );
26 
27  } else {
28 
29  // default
30  $rsArray = array();
31 
32  // performances
33  $tStart = microtime( true );
34 
35  // eseguo la query
36  $risultato = sqlsrv_query( $c, $q );
37 
38  // performances
39  $elapsedTime = microtime( true ) - $tStart;
40 
41  // se la query e' andata a buon fine
42  if( $risultato !== false ) {
43 
44  // fetch del risultato
45  while( $row = sqlsrv_fetch_array( $risultato, SQLSRV_FETCH_ASSOC ) ) {
46  $rsArray[] = $row;
47  }
48 
49  // archivio in cache la query
50  memcacheWrite( $m, $key, $rsArray );
51 
52  } else {
53 
54  $rsArray = false;
55 
56  }
57 
58  }
59 
60  // debug
61  // debugVar( $rsArray );
62 
63  // restituisco il risultato
64  return $rsArray;
65 
66  }
67 
68 ?>
$p['ricerca']
memcacheRead( $conn, $key)
$r
Definition: _osm.php:25
$e
Definition: _slack.php:121
mssqlCachedQuery( $m, $c, $q, $p=false, $t=MEMCACHE_DEFAULT_TTL, &$e=array())
memcacheWrite( $conn, $key, $data, $ttl=MEMCACHE_DEFAULT_TTL, $seed=MEMCACHE_UNIQUE_SEED)
const MEMCACHE_DEFAULT_TTL
Definition: _045.cache.php:16