There are many conflicting statements around. What is the best way to get the row count using PDO in PHP? Before using PDO, I just simply used mysql_num_rows
.>
Use parameter array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL)
, else show -1:
Usen parametro array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL)
, sin ello sale -1
example:
$res1 = $mdb2->prepare("SELECT clave FROM $tb WHERE id_usuario='$username' AND activo=1 and id_tipo_usuario='4'", array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL));
$res1->execute();
$count=$res1->rowCount();
echo $count;