SQL STATEMENT.... STRANGE BUG DISCOVERED

Game development with Board Game Arena Studio
Post Reply
User avatar
Rudolf
Posts: 566
Joined: 24 December 2011, 23:04

SQL STATEMENT.... STRANGE BUG DISCOVERED

Post by Rudolf »

Hello,
I just solved a Bug , but I still don't understand why the last sentence was not working proprerly...
I've been changing a

Code: Select all

$sql = "SELECT player_id, player_score FROM player ";
$result= self::getCollectionFromDb( $sql);

with 

$sql = "SELECT * FROM player ";
$result= self::getCollectionFromDb( $sql);

to get all the players... even I need few fields, if not, the "result" contains half of the players!!!!
Someone could explain to me why????
thanks.
User avatar
Victoria_La
Posts: 665
Joined: 28 December 2015, 20:55

Re: SQL STATEMENT.... STRANGE BUG DISCOVERED

Post by Victoria_La »

That should not affect number of rows, its may be the way you interpret the result which you did not share
Did you do $this->dump('rows',$result);
to check actual result?
User avatar
Morgalad
Posts: 110
Joined: 17 January 2017, 20:46
Contact:

Re: SQL STATEMENT.... STRANGE BUG DISCOVERED

Post by Morgalad »

Hi,
It could be due the way the collection is created, it takes one of the values as key of the array
and if you have several players with score 0 it could be that it has taken the score as key. So the players with 0 score overwrite the same position of the array. To interact with he players table even if you dont use it sometimes is useful to take the "player_no" (player number in the game) as first field in the query so that would avoid the behavior I described.
Cheers...
Morgalad

Developer of: Incan Gold , Takara Island , Taluva and Veggie Garden
User avatar
Rudolf
Posts: 566
Joined: 24 December 2011, 23:04

Re: SQL STATEMENT.... STRANGE BUG DISCOVERED

Post by Rudolf »

Hi...
Yes... it maybe a question of key, all scores are 1.
Thanks for answers... btw, I use SELECT * .
Post Reply

Return to “Developers”