Like postgres PDO with foreach

0

I need to use a like in foreach but without success, I did the following:

$arr = array('\'%a%\'', '\'%b%\'', '\'%c%\'');
foreach ($arr as $a){
   $this->SQL = "update client set active=1 where date between ? and ? and type like ?"
   $this->SQL =$this->PDO->prepare($this->SQL);
   $this->SQL->execute(array($this->Since, $this->Until, $a));
}

It runs but does not perform the update, I tried with var_dump to see what happened, but I did not succeed. Someone who has gone through this and managed to solve?

Thank you =]

    
asked by anonymous 09.08.2016 / 18:38

1 answer

1

If someone goes through the same problem, how can I solve it?

$arr = array('a', 'b', 'c');
foreach ($arr as $a){
   $this->SQL = "update client set active=1 where date between ? and ? and type like ?"
   $this->SQL =$this->PDO->prepare($this->SQL);
   $this->SQL->execute(array($this->Since, $this->Until, '%'.$a.'%'));
}

It is only necessary to pass the "%" in the parameters array.

Thanks to those who contributed.

    
12.08.2016 / 17:37