-1

I would like to know how to get the number of rows in a resultset for this statement:

$data=$db->query("SELECT name FROM users")->fetchAll();

I need something similar to mysqli_num_rows but using medoo.

thanks for your help!

Hechi
  • 281
  • 4
  • 14
  • If `count` is not an option, because of the specific query you are running, you would need to provide us with that specific query instead - otherwise, the answers below will be flooded with answers that aren't applicable. – gravity Jul 20 '16 at 13:35

3 Answers3

1

Since the query() method returns an array, just use php's count() function to determine the number of records returned (do not set the recursive mode).

Shadow
  • 33,525
  • 10
  • 51
  • 64
0

In the documentation there is a count method:

$count = $database->count("users");
ka_lin
  • 9,329
  • 6
  • 35
  • 56
  • Could you put the mentioned complex query (change table names if you want) to get an idea... – ka_lin Jul 20 '16 at 12:04
0

Try This: Counts the number of rows:

$count = $database->count($table, $where);
Harshad Hirapara
  • 462
  • 3
  • 12