1

my first Question was:

Problems with MYSQL IN Function PHP

I got good answers and followed the link in my previous question.

PHP - Using PDO with IN clause array

So i adapted my Code to this:

$in  = str_repeat('?,', count($arrWord) - 1) . '?';
$stmt = $this->pdo->prepare("SELECT * FROM `kunden` WHERE FAMNAME IN ($in) AND VORNAME IN ($in)");
$stmt->execute($arrWord);
$all = $stmt->fetchAll(PDO::FETCH_CLASS, $model);

but when i run the code the output from $all = array(0);

xdebug_output for $arrWord:

$arrWord = 
array(2)(
[0] => (string)Bob
[1] => (string)Ross
)

When i change the code to:

$in  = str_repeat('?,', count($arrWord) - 1) . '?';
$stmt = $this->pdo->prepare("SELECT * FROM `kunden` WHERE FAMNAME IN ($in)");
$stmt->execute($arrWord);
$all = $stmt->fetchAll(PDO::FETCH_CLASS, $model);

it works perfect and i got an output.

i tested my code with phpmyadmin and this was the output:

enter image description here

so my query is correct and I get output in phpmyadmin, but why not in php anybody know what my problem is?

best regards

Pesi
  • 81
  • 1
  • 6

0 Answers0