SQLite3相当于mysql_num_rows
SQLite3 中 mysql_num_rows 的等价物是什么? 我知道 SQLite 有类似的函数调用。我在 PHP 中所做的是在从查询中获取数组并计算变量的同时执行 for 操作,但我不太喜欢它。
What's the equivalent in SQLite3 to mysql_num_rows?
I know SQLite had a similar function call. What I'm doing in PHP is doing a for while fetching an array from the query and counting a variable but I don't like it very much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您有一个更改方法,它将为更新/删除方法提供 num 行/受影响的行功能。对于选择类型查询,您可以对结果集进行计数,或者有效地发出第二个请求来对上一个查询的结果进行计数(这将花费更多的时间给您的应用程序)。
对于“选择名字 = '约翰' 的用户”,这应该看起来像这样:
SELECT count(*) FROM (选择名字 = '约翰' 的用户) as tmp;
但这会花费您额外的查询,并且我很确定计算返回的结果集会更有效。
You have a changes method that will offer the num rows/affected rows functionality for update/delete methods. For select type queries, you can count the result set or effectively make a second request that will count the result of your previous query (will cost more time to your application).
For a "select users where firstname = 'john'" this should look something like this:
SELECT count(*) FROM ( select users where firstname = 'john' ) as tmp;
But it will cost you an extra query and i'm pretty sure that counting the returned result set will be more efficient.
名为
COUNT
的 SQL 查询怎么样?What about the SQL-query called
COUNT
?