I would like to get the count of the mysql query results in php.
The query usually returns up to 10 rows.
Which one in the below is better to use:
1.
$query = "SELECT * FROM test_table WHERE test_no=12345";
$queryResult = $db->query($query);
$count = $queryResult->size();
if($count < 5){}
2.
$query = "SELECT COUNT(test) AS count FROM test_table WHERE test_no=12345";
$queryResult = $db->query($query);
$result = $queryResult->fetch();
if($result['count'] < 5){}
Also, please let me know if there is another better way to use it