我正在将我的所有查询切换为PDO格式,而我特别遇到涉及IN()子句的问题.
$nba[0] = "Boston Celtics";
$nba[1] = "New York Knicks";
$nba[2] = "Houston Rockets";
$query = "SELECT game_id
FROM table
WHERE date_int >= :date_int
AND (home_team = :team OR away_team = :team)
AND home_team IN(:list)
AND away_team IN(:list)
ORDER BY game_date_int ASC
LIMIT 1";
$stmt = $db->prepare($query);
$stmt->execute(array(':date_int' => $limit,':team' => $team,':list' => implode(',',$nba)));
最佳答案
你可以像这样解决这个问题:
$nba = array();
$nba[0] = "Boston Celtics";
$nba[1] = "New York Knicks";
$nba[2] = "Houston Rockets";
$params = array(':date_int' => $limit,':team' => $team);
$nba_teams = array();
for($i=0;$i
尚未测试过,但我想你知道我在尝试什么