In mysql num_rows would return to me the number of selected records in a SELECT statement. I am using PDO now for SQL server and I am trying to find an equivalent function. I have tried the following but they do not work/ give what I am after.
$sql = "select * from tracker WHERE tms_key='575'";
$result = $conn->query($sql);
$count = $result->fetchColumn());
echo '$count: '.$count.'<br>';
foreach ($result as $row){
echo $row['cucm_tmsDeviceName'];
}
This just outputs:
$count: 575
Second approach:
$sql = "select * from tracker WHERE tms_key='575'";
$result = $conn->query($sql);
$count = $result->rowCount();
echo '$count: '.$count.'<br>';
foreach ($result as $row){
echo $row['cucm_tmsDeviceName'];
}
This outputs:
$count: -1
GMVC AR BA VICENTE LOPEZ COBALT