Im using below code to get result from database. Im expecting to get row count > 0 because I have 1 entry in database. Instead I'm getting the result below.
-1Array
(
[0] => stdClass Object
(
[lngID] => 1
[strRefTable] => team
[intFirstParent] =>
[intSecondParent] =>
[bitHasChild] =>
[strRefValue] => Automation
[strShortDesc] => Automation
[strLongDesc] => Automation
[strCreatedBy] => 181551
[dteCreatedDate] => 2019-03-27 09:09:08.000
[strUpdatedBy] => 181551
[dteUpdatedDate] => 2019-03-27 09:09:08.000
[bitActive] => 1
)
)
Where -1 represents the echo of $query->num_rows()
and the array proves that I have record in database.
$query = $db->query($sql);
if(!$query) {
throw new Exception('Server error');
}
echo $query->num_rows();exit();
print_r($query->result());die();
if($query->num_rows() > 0){
$result = $query->result();
}
Why do I get -1 as row count?
UPDATE
Using MSSQL