使用PHP mysqli获取UPDATE查询匹配的行数 [英] Get number of rows matched by UPDATE query with PHP mysqli

查看:72
本文介绍了使用PHP mysqli获取UPDATE查询匹配的行数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

较早的mysql扩展名具有CLIENT_FOUND_ROWS连接标记,但找不到 mysqli 的任何等效项.

The older mysql extension has the CLIENT_FOUND_ROWS connection flag, but I couldn't find any equivalent for mysqli.

我有一个update查询,想知道其where子句匹配的行数,而不是实际更改的行数(如mysqli -> affected_rows所示).

I have an update query and want to know how many rows its where clause matched, not how many were actually changed (as indicated by mysqli -> affected_rows).

到目前为止,我发现的唯一方法是使用正则表达式解析mysqli -> info(看起来像Rows matched: 40 Changed: 40 Warnings: 0).但这似乎很骇人.

The only way I've figured out so far is to parse mysqli -> info (which looks something like Rows matched: 40 Changed: 40 Warnings: 0) with a regex. But that seems hacky.

推荐答案

它在 mysqli_real_connect .

也在PHP 5.3中的PDO :: MySQL中引入.

Also introduced in PDO::MySQL in PHP 5.3.

这篇关于使用PHP mysqli获取UPDATE查询匹配的行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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