I am having a syntax issue with MDB2. Our framework uses this frequently so its kinda necessary that I use MDB2. I am trying to build a query with the LIKE mysql function and also trying to use %% to find any results close to the search but I keep getting PEAR errors. Here is the code I'm using.
public function searchThisUserField($field, $search) {
$statement = $this->readconnection->prepare("SELECT * FROM user WHERE " . $field . " LIKE %?% ORDER BY user_id ASC");
$data = array($search);
$result = $statement->execute($data);
if (PEAR::isError($result)){
dbg('problems finding with this search');
exit('problems finding results with this search');
} else {
return $result->fetchAll();
}
}
the problem lies with using modulus in the associative array $data. Can someone give me a solution? Would be greatly appreciated