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


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

Re: operatore jolly mysql

From Alessandro Pellizzari <shuriken@amiran.it>
Newsgroups it.comp.www.php
Subject Re: operatore jolly mysql
Date 2019-02-14 16:05 +0000
Message-ID <gclhusFd1r8U1@mid.individual.net> (permalink)
References (4 earlier) <gckv04F8uu0U1@mid.individual.net> <20190214114846.248af45e@nntp.aioe.org> <gckvn6F934qU1@mid.individual.net> <20190214120055.4b5f1b19@nntp.aioe.org> <20190214162342.51129c53@nntp.aioe.org>

Show all headers | View raw


On 14/02/2019 15:23, Enrico Maria Chellini wrote:

> In pratica, per fare un esempio, se ho  le relative opzioni
> |provincia|località|categoria|camere|cucina|bagno|ariacondizionata|piscina|forno|tv|etc.
> 
> dovrò scrivere una query per ogni combinazione richiesta o sbaglio?
> 
> cosa mi son perso?

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;
}


Bye.

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