多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] ## 执行SQL返回第一行 **pdo_fetch** ## 执行SQL返回全部记录 **pdo_fetchall** ~~~ pdo_fetchall(string $sql, [array $params], [string $keyfield]); ~~~ **参数** | | | | -- | -- | |$sql |string |需要执行的SQL语句| |$params |array |参数列表| |$keyfield |string |将该字段的值作为结果索引| **返回值** > 执行SQL返回全部记录, 如果参数列表错误,返回 false。如果可选参数 $keyfield 不为空,则将该字段的值作为结果数组索引。 **示例** ~~~ $sql = 'SELECT * FROM ' . tablename('account') . ' WHERE `acid` > :acid'; $params = array(':acid' => '400'); $accounts = pdo_fetchall($sql, $params); print_r($accounts); Array ( [0] => Array ( [acid] => 434 [uniacid] => 288 [hash] => M3BaP3WR [type] => 1 [isconnect] => 0 ) [1] => Array ( [acid] => 433 [uniacid] => 288 [hash] => I01dujgC [type] => 1 [isconnect] => 0 ) [2] => Array ( [acid] => 440 [uniacid] => 444 [hash] => E33pwA88 [type] => 1 [isconnect] => 1 ) ) ~~~