答案 0 :(得分:7)
以下是使用PDO
执行此操作的简单方法$stmt = $pdo->prepare("SELECT Column FROM foo LIMIT 5");
$stmt->execute();
$array = $stmt->fetchAll(PDO::FETCH_UNIQUE | PDO::FETCH_GROUP);
var_dump(array_keys($array));
array(5) {
[0]=>
int(7960)
[1]=>
int(7972)
[2]=>
int(8028)
[3]=>
int(8082)
[4]=>
int(8233)
}
答案 1 :(得分:-2)
$ link = mysqli_connect($ host,$ user,$ password) 或者死掉('数据库服务器连接错误' .mysqli_error());
mysqli_select_db($链路,$数据库) 或死('数据库选择错误' .mysqli_error());
$ sql =' SELECT FROM FROM Customers';
$ query = mysqli_query($ link,$ sql);
if(0< mysqli_num_rows($ query)) {
while($data = mysqli_fetch_assoc($query))
{
$resultArray[] = $data['name'];
}
}