Я использую уровень абстракции базы данных Doctrine (DBAL) для выполнения некоторых запросов.По какой-то причине, когда я цитирую параметр перед передачей его в запрос, я не получаю никаких строк.Когда я передаю его без кавычек, он работает нормально.
Вот соответствующий фрагмент кода, который я использую:
public function get($game)
{
load::helper('doctrinehelper');
$conn = doctrinehelper::getconnection();
$statement = $conn->prepare('SELECT games.id as id, games.name as name, games.link_url, games.link_text, services.name as service_name, image_url
FROM games, services
WHERE games.name = ?
AND services.key = games.service_key');
$quotedGame = $conn->quote($game);
load::helper('loghelper');
$logger = loghelper::getLogger();
$logger->debug("Quoted Game: $quotedGame");
$logger->debug("Unquoted Game: $game");
$statement->execute(array($quotedGame));
$resultsArray = $statement->fetchAll();
$logger->debug("Number of rows returned: " . count($resultsArray));
return $resultsArray;
}
Вот что показывает журнал:
01/01/11 17:00:13,269 [2112] DEBUG root - Quoted Game: 'Diablo II Lord of Destruction'
01/01/11 17:00:13,269 [2112] DEBUG root - Unquoted Game: Diablo II Lord of Destruction
01/01/11 17:00:13,270 [2112] DEBUG root - Number of rows returned: 0
Если я изменю эту строку:
$statement->execute(array($quotedGame));
на это:
$statement->execute(array($game));
Я получу это в журнале:
01/01/11 16:51:42,934 [2112] DEBUG root - Quoted Game: 'Diablo II Lord of Destruction'
01/01/11 16:51:42,935 [2112] DEBUG root - Unquoted Game: Diablo II Lord of Destruction
01/01/11 16:51:42,936 [2112] DEBUG root - Number of rows returned: 1
Я что-то жирный перебрал?