how do i get the number of rows resulted in libasynql? Trying to check if player exists in mysql database through select * from db where uuid=:uuid But how do I get how many numbers of rows resulted from the query PHP: public function accountExists ( Player $player, callable $callable ) { if ( !$player instanceof Player ) { return; } $uuid = $player->getUniqueId(); $this->connector->executeSelect( Queries::GET_ALL, [ "uuid" => (string)$uuid, ], $callable ); } PHP: public function join(PlayerJoinEvent $event){$this->provider()->accountExists( $player, function ( array $result ) use ( $player, $uuid) { if ( $result number of rows < 0 ) { // create player } else { // store player to array } } );}
All I am doing this for is to check if the player is in the database. Should I just use if(!$player->hasPlayedBefore()){ // and then create account instead of querying mysql?
COUNT(*) is an aggregate function that returns the number of rows matching the query. It always returns exactly one row, containing the count. Never use num_rows if you are just interested in the number of rows available; use COUNT(*) for that case. num_rows is used when you have not fetched all the rows, but libasynql fetches everything asynchronously first