我是PHP的新手,想知道为什么我的like查询只返回一个值。这是我的模特//For searchpublic function getSearchResults($username){ $stmt = $this->_connection->prepare("SELECT * FROM users WHERE username LIKE :username"); $stmt->execute(['username' => '%'.$username.'%']); $stmt->setFetchMode(PDO::FETCH_CLASS, "User"); return $stmt->fetch();}然后在我的控制器中function search($name){ //Get search results $searchResults = $this->model('User'); $searchResults = $searchResults->getSearchResults($name); $data = (array) $searchResults; $this->view('User/search', $data);}但是,它仅返回1个结果,而不是3个结果。(我有4个用户名,其中带有“ hi”,但仅返回一个)
- 1 回答
- 0 关注
- 195 浏览
添加回答
举报
0/150
提交
取消