我有一个简单的查询,从我的数据库中的库存表中返回所有ISBN,总共应该返回大约6650个结果但由于某种原因PDO :: FETCH_COLUMN很短,更改我只返回4851结果,下面是两个我用于使用pdo mysql检索数据的不同函数
php中的函数
/* returns all select results in multi-dimensional arrays */
public function select($query){
try{
$stmt = $this->dbh->query($query);
$arr = array();
while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
$arr[] = $row;
}
return $arr;
}catch(PDOException $e){
echo "Error with select_array function: ".$e->getMessage();
}
}
/* returns only one column in one array, used when selecting one column */
public function select_one_column($query){
try{
$stmt = $this->dbh->query($query);
$arr = array();
while($row = $stmt->fetch(PDO::FETCH_COLUMN)){
$arr[] = $row;
}
return $arr;
}catch(PDOException $e){
echo "Error with select_array function: ".$e->getMessage();
}
}
使用示例
$query = "select isbn from inventory";
print_r($this->select($query));
array(
[0] => Array
(
[isbn] => 1843060469
)
[1] => Array
(
[isbn] => 184306152X
)
)
print_r($this->select_one_colum($query));
array(
[0] => 1843060469
[1] => 184306152X
)
可能导致此问题的原因是什么?