我对 PHP 函数 'mysql_fetch_assoc()' 有疑问
public function result ($query) {
$result = false;
if (is_resource($this->resourceHandler)) {
$result = array();
while ($tempVar = @mysql_fetch_assoc($query)) {
$result[] = $tempVar;
}
}else{
throw new Exception ('Keine Verbindung zur Datenbank vorhanden!');
}
return $result;
}
当我运行此函数时,返回的数组应如下所示:
[0] => Array
(
[id] => 1
[description] => Test
[date] => 2012-08-09
)
[1] => Array
(
[nummer] => 2
[beschreibung] => Test2
[datum] => 2012-08-09
)
[2] => Array
(
[nummer] => 3
[beschreibung] => test3
[datum] => 2012-08-10
)
但它看起来像这样:
[0] => Array
(
[id] => 1
[description] => Test
[date] => 2012-08-09
)
[1] => Array
(
[nummer] =>
[beschreibung] =>
[datum] => 1970-01-01
)
[2] => Array
(
[nummer] => 3
[beschreibung] => test3
[datum] => 2012-08-10
)
我的数组的第二个元素总是空的。无论使用哪个 sql-query。有人知道这个问题吗?