PHP Function to validate setting

True. Unless you want to display the data.

== 1, > 0, < 1, and many other ones aren’t necessary. Normally you would find those conditions on a tutorial for noobies. With num_rows and rowCount, if the data exists, it’ll return a 1 which means true. If the data doesn’t exist, it’ll return a 0 which means false. In any case it would be like if(true == true) when you already know it’s already true and will always return the first error checking. False would always be returned in the else statement. That’s being really redundant so it’s not really necessary to repeat one’s self by comparing the condition when the data is returned as true already.

So this is fine if you were to use it in an if statement.

if($prepare->rowCount()) {

or

if($prepare->num_rows) {
1 Like