public function suggest(){
$SQL = "SELECT CategoryName FROM tb_category WHERE CategoryName LIKE CONCAT('%', ?, '%')";
$stmt = $this->_db->mysqli->prepare($SQL);
$stmt->bind_param("s", $this->querystring);
$stmt->execute();
$meta = $stmt->result_metadata();
while($field = $meta->fetch_field())
{
$parameters[] = &$row[$field->name];
//print_r($parameters);
}
In my while
-loop its giving the on thing again and again just checking the single row in db not the whole table I guess there isn't any problem with like operator here
Just to be sure i understood well:
while($field = $meta->fetch_field())
{
$parameters[] = &$row[$field->name];
//print_r($parameters);
}
Suppose you query returns 10 rows, does this while execute 10 times?
Try $row[$field->name];
instead of &$row[$field->name];
(without &
)
finally fetch_field()
returns the definitions of the columns you retreived with your query. As you select only CategoryName
you are printing only CategoryName
column definitions