Heim  >  Artikel  >  Backend-Entwicklung  >  php的pdo::statement的rowCount方法能否返回select语句受影响的函数?

php的pdo::statement的rowCount方法能否返回select语句受影响的函数?

WBOY
WBOYOriginal
2016-08-25 10:37:221201Durchsuche

如下图所示:

php的pdo::statement的rowCount方法能否返回select语句受影响的函数?

php的pdo::statement的rowCount方法能否返回select语句受影响的函数?

回复内容:

如下图所示:

php的pdo::statement的rowCount方法能否返回select语句受影响的函数?

php的pdo::statement的rowCount方法能否返回select语句受影响的函数?

受影响指的是被改动的行数,SELECT查询并不会改动行的内容.

http://php.net/pdo
pdo中,用count计算结果集数组得到select查询到的行数,rowCount()存储了查询(insert/update/delete)中受影响(改动)的行数.

http://php.net/mysqli
mysqli中,num_rows(开启缓冲查询时才有效)存储了select查询到的行数,affected_rows存储了查询(insert/update/delete)中受影响(改动)的行数.

值得注意的是,update时,如果更新的内容跟原来的内容一样,mysqli的affected_rows,pdo的rowCount()也会返回0.

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn