If you are familiar with OOP concepts in PHP, then you will be able to understand what is going on here, else I recommend you to firstly get your hands dirty with OOP in PHP
Here $erg->num_rows
is not a condition. ->
operator is used to access any attribute of the pointing class instance.
In simple words, this line:
if ($erg->num_rows)
checks if the number of rows is greater than zero (as suggested by the variable name), if yes then the following code will be executed.
Because 0
is false
and any other number is true
. That means if $erg->num_rows
returns 0
then condition will be evaluated to false
and if it returns value that is not 0
, then condition will be evaluated to true
.
->
operator has nothing to do with if
statements.