Home > Backend Development > PHP Tutorial > php取出数据库数据后,var_dump(),id字段为什么是字符串类型?

php取出数据库数据后,var_dump(),id字段为什么是字符串类型?

WBOY
Release: 2016-06-06 20:22:19
Original
1704 people have browsed it

php取出数据库数据后,var_dump(),id字段为什么是字符串类型?
php取出数据库数据后,var_dump(),id字段为什么是字符串类型?

<code>$sqlcomment ="SELECT * FROM comment WHERE pid={$id}";
$rescomment = $datebase->DBfetch($sqlcomment);
var_dump($rescomment);</code>
Copy after login
Copy after login

var_dump(),id字段为什么是字符串类型?

回复内容:

php取出数据库数据后,var_dump(),id字段为什么是字符串类型?
php取出数据库数据后,var_dump(),id字段为什么是字符串类型?

<code>$sqlcomment ="SELECT * FROM comment WHERE pid={$id}";
$rescomment = $datebase->DBfetch($sqlcomment);
var_dump($rescomment);</code>
Copy after login
Copy after login

var_dump(),id字段为什么是字符串类型?

因为返回数组的时候底层就被转成字符串了。

可以吧PDO::ATTR_EMULATE_PREPARES设为false,就不会自动转了。
还有就是使用代码转,TP和YII2我都有看过,实现方式类似。

这个是TP例子解决PHP从数据库取出字段全为字符串类型

Related labels:
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