-
Notifications
You must be signed in to change notification settings - Fork 25
Add num rows functions #5
Comments
Hello @Codez1337 , You can use for example: $result = $db->query("SELECT * FROM users");
echo $result->num_rows; //how many users
$db->query("DELETE from users WHERE active = 0");
echo $db->affected_rows() //how many rows were deleted; |
a question which i must ask and may look stupid, but how do you use that in an if statement? i want to count the rtows and if there are not enough then exit that part of the script. now i know that the old mysql way works but i am trying to get into using classes and oop so how would i do it with this? I ask because i am getting errors trying to do it the old way. |
well its quite simple, properties work like variables, actually this so you can use it like this if($result->num_rows==0){
//empty
}
if(!$result->num_rows){
//empty
} or like this: if($result->num_rows){
//not empty!
} |
so the var i name the query becomes an object? |
@Codez1337 , well, yes, it returns a resultset object that helps you access your data |
We need a num rows function added.
The text was updated successfully, but these errors were encountered: