绑定变量(SELECT *),如何返回所有结果

WBOY
Release: 2016-06-23 14:26:40
Original
1046 people have browsed it

$stmt = $mysqli->prepare("SELECT * FROM Country ORDER BY Name LIMIT 5")) {
$stmt->execute();
 /* bind variables to prepared statement */
$stmt->bind_result($col1, $col2);


// 如何能够把 bind_result()绑定所有的列,前提是我不知道 * 里有多少字段。

我的目的要实现:  

1、SELECT *  ……查询;
2、返回所有结果到一个所有记录的数组;

从网上找了各种资料也没有得到结论。


回复讨论(解决方案)

SHOW FIELDS FROM 表名;
desc 表名;

楼上的与我问的题牛头不对马尾

既然是有多少字段,那么也就不可能知道有多少被绑定的变量
那么绑定所有的列有什么意义呢?

$stmt = $mysqli->prepare("SELECT * FROM Country ORDER BY Name asc");

SHOW FIELDS FROM 表名;
然后循环绑定不可以么?

SHOW FIELDS FROM 表名;
desc 表名; $stmt->bind_result($col1, $col2);

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!