I did the following code but for some reason the search is not working is not looking first name and last name. i get all table.
$table = $this->getDbTable();
$select = $table->select();
$select->where(
'CONCAT(firstname, " ", lastname) LIKE ?',
'%' . strip_tags($search) . '%'
);
$rows = $table->fetchAll($select);
Try it
$table = $this->getDbTable();
$select = $table->select();
$select->from(...);
$select->where(new \Zend\Db\Sql\Expression('CONCAT(firstname, " ", lastname) LIKE %?%'), $search);
$rows = $table->fetchAll($select);
Simply,
Use combined where
and orWhere
methods
$table = $this->getDbTable();
$select = $table->select();
$select->where('firstname = ?', $search)
->orWhere('lastname = ?', $search);
$rows = $table->fetchAll($select);
Hope it helps.
$select->where("CONCAT(name_first,name_last) LIKE ?","%$keyword%");