我有以下代码序列:
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 似乎是空的,我不知道为什么。