当$this->show
设置为 时,准备好的查询返回以下结果集saved-by-the-bell
:
season
------
1
2
3
4
当我执行以下代码时:
$seasons = array( );
$query = $db->prepare(
"SELECT `season` " .
"FROM `tv` " .
"WHERE `show_url` = ':show' " .
"GROUP BY `season` " .
"ORDER BY `season` ASC;"
);
$query->bindParam( ':show', $this->show );
$query->execute( );
$query->setFetchMode( PDO::FETCH_OBJ );
while( $row = $query->fetch( ) )
{
$season = new stdClass;
$season->number = $row->season;
$season->title = "Season {$row->season}";
$season->url = $row->season;
$seasons[] = $season;
}
return $seasons;
$seasons
是一个空数组,为什么?
$db 是扩展 PDO 的实例化对象。
我尝试了各种调试方法,但是当我回显 rowCount 时,它显示为 0。我还是 PDO 的新手,但我似乎看不出这里有什么问题。
提前致谢。