Php 搜索名字和姓氏ZEND
我执行了以下代码,但由于某些原因,搜索不起作用,无法查找名字和姓氏。 我得到所有的桌子Php 搜索名字和姓氏ZEND,php,zend-framework,Php,Zend Framework,我执行了以下代码,但由于某些原因,搜索不起作用,无法查找名字和姓氏。 我得到所有的桌子 $table = $this->getDbTable(); $select = $table->select(); $select->where( 'CONCAT(firstname, " ", lastname) LIKE ?', '%' . strip_tags($search) . '%' ); $rows = $table->fetchAll($selec
$table = $this->getDbTable();
$select = $table->select();
$select->where(
'CONCAT(firstname, " ", lastname) LIKE ?',
'%' . strip_tags($search) . '%'
);
$rows = $table->fetchAll($select);
简单地说
使用组合的where
和或where
方法
$table = $this->getDbTable();
$select = $table->select();
$select->where('firstname = ?', $search)
->orWhere('lastname = ?', $search);
$rows = $table->fetchAll($select);
希望有帮助。试试看
$table = $this->getDbTable();
$select = $table->select();
$select->from(...);
$select->where(new \Zend\Db\Sql\Expression('CONCAT(firstname, " ", lastname) LIKE %?%'), $search);
$rows = $table->fetchAll($select);
$search只是一个点吗?我不明白你的意思。你确定
$search
有值吗?
$select->where("CONCAT(name_first,name_last) LIKE ?","%$keyword%");