私は次のコードシーケンスを持っています:
if (is_array($team) && !empty($team)) {
$where_clause = "WHERE te.name IN (";
$in_elems = array();
foreach ($team as $key => $value) {
$in_elems[] = "':team_$key'";
}
$where_clause .= implode(',', $in_elems) . " )";
$query = "SELECT p.name FROM " . Yii::app()->params['team_tbl'] . " te
LEFT JOIN " . Yii::app()->params['player_tbl'] . " p ON te.id = p.team_id
$where_clause
ORDER BY te.name, p.name ASC
";
$command = $conn->createCommand($query);
foreach ($team as $key => $value) {
$command->bindValue(":team_$key", $value);
}
} else {
....
}
if ($command) {
$dataReader = $command->query();
print_R($dataReader->count()); ---> here is 0!!!
while(($player = $dataReader->read()) !== false) {
$players[] = array(
'label'=>$player['name'],
'id'=>$player['name'],
);
}
このコード シーケンスを実行すると、dataReader が空のように見え、その理由がわかりません。