我们如何获取数组中表的所有行? [英] How can we fetch all rows of a table in an array?

查看:58
本文介绍了我们如何获取数组中表的所有行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何获取数组中表的所有行? 该表未通过php PDO连接 到目前为止,我已经尝试过以下返回结果集的最后一行.

How can we fetch all rows of a table in an array? This table is not connected via php PDO so far Ive tried the following returns last row of the resultset.

    $sth = $dbh->query("show tables;"); //select
    $sth->setFetchMode(PDO::FETCH_ASSOC);

    $results= $sth->fetch();

    print_r($results);

推荐答案

您可以使用 fetchAll

$sth = $dbh->query("show tables;"); //select
$sth->setFetchMode(PDO::FETCH_ASSOC);
$results= $sth->fetchAll();

var_dump($results);

这篇关于我们如何获取数组中表的所有行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆