开发者

SQLite3 equivalent to mysql_num_rows

What's the equi开发者_如何学编程valent 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.


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.


What about the SQL-query called COUNT?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜