GlisWeb framework
_collation.php
Vai alla documentazione di questo file.
1 <?php
2 
15  // inclusione del framework
16  require '../../../_src/_config.php';
17 
18  // query NON preparata
19  $tx = 'SELECT standard: ' . PHP_EOL;
20  $tx .= print_r( mysqlQuery( $cf['mysql']['connection'], 'SELECT * FROM categorie_prodotti_view WHERE __label__ LIKE "%ova1%"' ), true );
21 
22  // query preparata
23  $tx .= 'SELECT preparata: ' . PHP_EOL;
24  $tx .= print_r( mysqlQuery( $cf['mysql']['connection'], 'SELECT * FROM categorie_prodotti_view WHERE __label__ LIKE ?', array( array( 's' => '%pr%' ) ) ), true );
25 
26  // query preparata di test
27  $tx .= 'SELECT preparata di test sulla colonna nome: ' . PHP_EOL;
28  $tx .= print_r( mysqlQuery( $cf['mysql']['connection'], 'SELECT * FROM categorie_prodotti_view WHERE nome LIKE ?', array( array( 's' => '%pr%' ) ) ), true );
29 
30  // query preparata di test
31  $tx .= 'SELECT preparata di test sulla colonna __label__ senza LIKE: ' . PHP_EOL;
32  $tx .= print_r( mysqlQuery( $cf['mysql']['connection'], 'SELECT * FROM categorie_prodotti_view WHERE __label__ = ?', array( array( 's' => 'prova1' ) ) ), true );
33 
34  // query preparata di test
35  $tx .= 'SELECT preparata di test sulla colonna __label__ senza wildcards: ' . PHP_EOL;
36  $tx .= print_r( mysqlQuery( $cf['mysql']['connection'], 'SELECT * FROM categorie_prodotti_view WHERE __label__ LIKE ?', array( array( 's' => 'prova1 > prova11' ) ) ), true );
37 
38  // query preparata
39  $tx .= 'SELECT preparata con concatenazione delle wildcards: ' . PHP_EOL;
40  $tx .= print_r( mysqlQuery( $cf['mysql']['connection'], 'SELECT * FROM categorie_prodotti_view WHERE __label__ LIKE CONCAT(\'%\',?,\'%\')', array( array( 's' => 'pr' ) ) ), true );
41 
42  // bind "naturale"
43  $tx .= 'SELECT con bind "naturale": ' . PHP_EOL;
44  $pq = mysqli_prepare( $cf['mysql']['connection'], 'SELECT * FROM categorie_prodotti_view WHERE __label__ LIKE ?' );
45  $lk = '%ova1%';
46  mysqli_stmt_bind_param( $pq, 's', $lk);
47  mysqli_stmt_execute( $pq );
48  $tx .= print_r( mysqlFetchPreparedResult( $pq ), true );
49  $tx .= mysqli_errno( $cf['mysql']['connection'] ) . ' ' . mysqli_error( $cf['mysql']['connection'] ) . PHP_EOL;
50  mysqli_stmt_close( $pq );
51 
52  // bind "naturale"
53  $tx .= 'SELECT con bind "naturale" e convert: ' . PHP_EOL;
54  $pq = mysqli_prepare( $cf['mysql']['connection'], 'SELECT * FROM categorie_prodotti_view WHERE convert( __label__ using utf8 ) LIKE ?' );
55  $lk = '%ova1%';
56  mysqli_stmt_bind_param( $pq, 's', $lk);
57  mysqli_stmt_execute( $pq );
58  $tx .= print_r( mysqlFetchPreparedResult( $pq ), true );
59  $tx .= mysqli_errno( $cf['mysql']['connection'] ) . ' ' . mysqli_error( $cf['mysql']['connection'] ) . PHP_EOL;
60  mysqli_stmt_close( $pq );
61 
62  // bind "naturale"
63  $tx .= 'SELECT con bind "naturale" e collate: ' . PHP_EOL;
64  $pq = mysqli_prepare( $cf['mysql']['connection'], 'SELECT * FROM categorie_prodotti_view WHERE __label__ LIKE ? COLLATE utf8_unicode_ci' );
65  $lk = '%ova1%';
66  mysqli_stmt_bind_param( $pq, 's', $lk);
67  mysqli_stmt_execute( $pq );
68  $tx .= print_r( mysqlFetchPreparedResult( $pq ), true );
69  $tx .= mysqli_errno( $cf['mysql']['connection'] ) . ' ' . mysqli_error( $cf['mysql']['connection'] ) . PHP_EOL;
70  mysqli_stmt_close( $pq );
71 
72  // bind "naturale"
73  $tx .= 'SELECT con bind "naturale" sulla colonna nome: ' . PHP_EOL;
74  $pq = mysqli_prepare( $cf['mysql']['connection'], 'SELECT * FROM categorie_prodotti_view WHERE nome LIKE ?' );
75  $lk = '%ova1%';
76  mysqli_stmt_bind_param( $pq, 's', $lk);
77  mysqli_stmt_execute( $pq );
78  $tx .= print_r( mysqlFetchPreparedResult( $pq ), true );
79  $tx .= mysqli_errno( $cf['mysql']['connection'] ) . ' ' . mysqli_error( $cf['mysql']['connection'] ) . PHP_EOL;
80  mysqli_stmt_close( $pq );
81 
82  // output
83  build( $tx );
84 
85 ?>
$lk
Definition: _collation.php:45
mysqlQuery( $c, $q, $p=false, &$e=array())
$cf['ricerca']['template']
Definition: _030.common.php:7
$pq
Definition: _collation.php:44
mysqlFetchPreparedResult( $r)
$tx
Definition: _collation.php:19
build( $content, $type=MIME_TEXT_PLAIN, $encoding=ENCODING_UTF8, $headers=array())