Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 搜索名字和姓氏ZEND_Php_Zend Framework - Fatal编程技术网

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%");