There are more placeholders than passed parameters
Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
- matlej
- Člen | 10
Dobrý deň,
snažím sa o klasický bind parametrov, ale stále mi
vypisuje There are more placeholders than passed parameters
/** @return Nette\Database\Table\Selection */
public function findByUserFilter($filter, $offset, $own)
{
$sql = 'SELECT info_status_all.servers_game_id,
info_status_all.hostname,
info_status_all.map,
info_status_all.active_players,
info_status_all.max_players,
CONCAT(
servers_game.ip,
":",
servers_game.port
) AS ip_port,
servers_game.web AS web,
games.name AS game_name,
IF(
servers_game.status = 1,
"on",
"off"
) AS status
FROM info_status_all
LEFT JOIN servers_game
ON info_status_all.servers_game_id = servers_game.servers_game_id
LEFT JOIN games
ON servers_game.games_id = games.games_id
WHERE games.name = ?
OR games.name LIKE ?
ORDER BY status DESC
LIMIT 20 OFFSET ?';
return $this->db->query($sql, [$filter, "%" . $own . "%", $offset])->fetchAll();
}
- David Matějka
- Moderator | 6445
metoda query akceptuje parametry jako jednotlive argumenty, takze pouzij
->query($sql, $filter, "%" . $own . "%", $offset)
nebo pouzij metodu queryArgs, ktera akceptuje pole, jak to ted delas