Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > it.comp.www.php > #22565

Re: operatore jolly mysql

From Enrico Maria Chellini <bitit@bitit.it>
Newsgroups it.comp.www.php
Subject Re: operatore jolly mysql
Date 2019-02-14 17:41 +0100
Organization Aioe.org NNTP Server
Message-ID <20190214174108.2abed106@nntp.aioe.org> (permalink)
References (5 earlier) <20190214114846.248af45e@nntp.aioe.org> <gckvn6F934qU1@mid.individual.net> <20190214120055.4b5f1b19@nntp.aioe.org> <20190214162342.51129c53@nntp.aioe.org> <gclhusFd1r8U1@mid.individual.net>

Show all headers | View raw


> Io costruisco le query dinamicamente. Esempio al volo senza test:
> 
> function search($prov, $loc, $cat, $camere, ...) {
>    $wheres = [];
> 
>    if (!is_null($prov)) {
>      $wheres['provincia'] = $prov;
>    }
>    if (!is_null($loc)) {
>      $wheres['località'] = $loc;
>    }
>    ...
> 
>    $query = "select * from dati where ";
>    $query .= implode(
>      ' and ',
>      array_map(
>        function($k) { return $k . '= :' .$k; },
>        $wheres
>      )
>    );
> 
>    $stmt = $this->pdo->prepare($query);
>    $res = $stmt->execute($wheres);
>    // o qualcosa del genere
> 
>    return $res;
> }
> 

Più chiaro .

ma hai pulito le variabili $prov,  $loc, $cat, $camere ... ?

altrimenti si potrebbe annidare li dentro un sqlinjection  o sbaglio?

Enrico 
 

Back to it.comp.www.php | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

operatore jolly mysql Enrico Maria Chellini <bitit@bitit.it> - 2019-02-13 12:28 +0100
  Re: operatore jolly mysql Enrico Maria Chellini <bitit@bitit.it> - 2019-02-13 16:11 +0100
    Re: operatore jolly mysql fmigliori <fmigliori@gmail.com> - 2019-02-13 12:30 -0800
      Re: operatore jolly mysql Enrico Maria Chellini <bitit@bitit.it> - 2019-02-14 11:30 +0100
        Re: operatore jolly mysql Alessandro Pellizzari <shuriken@amiran.it> - 2019-02-14 10:42 +0000
          Re: operatore jolly mysql Enrico Maria Chellini <bitit@bitit.it> - 2019-02-14 11:48 +0100
            Re: operatore jolly mysql Alessandro Pellizzari <shuriken@amiran.it> - 2019-02-14 10:54 +0000
              Re: operatore jolly mysql Enrico Maria Chellini <bitit@bitit.it> - 2019-02-14 12:00 +0100
                Re: operatore jolly mysql Enrico Maria Chellini <bitit@bitit.it> - 2019-02-14 16:23 +0100
                Re: operatore jolly mysql logica mente <npaolini_no_spam_@ennepisoft.it> - 2019-02-14 16:57 +0100
                Re: operatore jolly mysql Alessandro Pellizzari <shuriken@amiran.it> - 2019-02-14 16:11 +0000
                Re: operatore jolly mysql logica mente <npaolini_no_spam_@ennepisoft.it> - 2019-02-14 18:41 +0100
                Re: operatore jolly mysql Enrico Maria Chellini <bitit@bitit.it> - 2019-02-14 17:21 +0100
                Re: operatore jolly mysql Alessandro Pellizzari <shuriken@amiran.it> - 2019-02-14 16:48 +0000
                Re: operatore jolly mysql Alessandro Pellizzari <shuriken@amiran.it> - 2019-02-14 16:05 +0000
                Re: operatore jolly mysql Enrico Maria Chellini <bitit@bitit.it> - 2019-02-14 17:41 +0100
                Re: operatore jolly mysql Alessandro Pellizzari <shuriken@amiran.it> - 2019-02-14 17:08 +0000
                Re: operatore jolly mysql Enrico Maria Chellini <bitit@bitit.it> - 2019-02-14 18:25 +0100
                Re: operatore jolly mysql Alessandro Pellizzari <shuriken@amiran.it> - 2019-02-14 21:28 +0000
                Re: operatore jolly mysql Enrico Maria Chellini <bitit@bitit.it> - 2019-02-15 11:01 +0100
                Re: operatore jolly mysql Alessandro Pellizzari <shuriken@amiran.it> - 2019-02-15 16:56 +0000
                Re: operatore jolly mysql Enrico Maria Chellini <bitit@bitit.it> - 2019-02-15 18:47 +0100
                Re: operatore jolly mysql Enrico Maria Chellini <bitit@bitit.it> - 2019-02-15 19:41 +0100
                Re: operatore jolly mysql Enrico Maria Chellini <bitit@bitit.it> - 2019-02-16 13:01 +0100
                Re: operatore jolly mysql Enrico Maria Chellini <bitit@bitit.it> - 2019-02-16 15:35 +0100
                Re: operatore jolly mysql Enrico Maria Chellini <bitit@bitit.it> - 2019-02-16 16:18 +0100
                Re: operatore jolly mysql Enrico Maria Chellini <bitit@bitit.it> - 2019-02-15 12:47 +0100
                Re: operatore jolly mysql Enrico Maria Chellini <bitit@bitit.it> - 2019-02-15 14:07 +0100
                Re: operatore jolly mysql Enrico Maria Chellini <bitit@bitit.it> - 2019-02-15 15:08 +0100
                Re: operatore jolly mysql Enrico Maria Chellini <bitit@bitit.it> - 2019-02-15 15:41 +0100
                Re: operatore jolly mysql fmigliori <fmigliori@gmail.com> - 2019-02-15 07:44 -0800
                Re: operatore jolly mysql Enrico Maria Chellini <bitit@bitit.it> - 2019-02-15 17:28 +0100
                Re: operatore jolly mysql fmigliori <fmigliori@gmail.com> - 2019-02-15 10:27 -0800
                Re: operatore jolly mysql Enrico Maria Chellini <bitit@bitit.it> - 2019-02-15 20:15 +0100
                Re: operatore jolly mysql fmigliori <fmigliori@gmail.com> - 2019-02-15 11:37 -0800
                Re: operatore jolly mysql Enrico Maria Chellini <bitit@bitit.it> - 2019-02-16 16:02 +0100
                Re: operatore jolly mysql Enrico Maria Chellini <bitit@bitit.it> - 2019-02-21 12:21 +0100
                Re: operatore jolly mysql fmigliori <fmigliori@gmail.com> - 2019-02-21 04:33 -0800
                Re: operatore jolly mysql Enrico Maria Chellini <bitit@bitit.it> - 2019-02-21 14:37 +0100
                Re: operatore jolly mysql Enrico Maria Chellini <bitit@bitit.it> - 2019-02-21 16:27 +0100
                Re: operatore jolly mysql Enrico Maria Chellini <bitit@bitit.it> - 2019-02-21 12:39 +0100
                Re: operatore jolly mysql fmigliori <fmigliori@gmail.com> - 2019-02-21 04:43 -0800
                Re: operatore jolly mysql Enrico Maria Chellini <bitit@bitit.it> - 2019-02-21 14:38 +0100

csiph-web