0
I need to use a like in foreach but without success, I did as follows:
$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 update, I tried with var_dump to see what happened, but I was not successful. Someone who’s been through it and managed to work it out?
Thank you =]
Thanks for the collaboration, but I was only wrong to pass the example here, in the original code this with the 'and'. abç
– Christopher Tavares
You don’t need to escape the jokers, see
– rray
no escape returns like this (my production example): Array ( [0] => 42601 [1] => 7 [2] => ERROR: syntax error at or near "$3" LINE 1: ...t = 0 Where cmdatecreate between $1 and $2 and cmtext in $3 ^ )
– Christopher Tavares
It says that the error is in the value passed to the like or before.
– rray
$1 and $2 I know it’s not the problem, in the third step as ta the above array without the escapes, to try with foreach ( $arr as $a => $value)
– Christopher Tavares