Page 1 of 1

SQL STATEMENT.... STRANGE BUG DISCOVERED

Posted: 22 July 2017, 02:56
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.

Re: SQL STATEMENT.... STRANGE BUG DISCOVERED

Posted: 22 July 2017, 14:51
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?

Re: SQL STATEMENT.... STRANGE BUG DISCOVERED

Posted: 22 July 2017, 18:35
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.

Re: SQL STATEMENT.... STRANGE BUG DISCOVERED

Posted: 29 July 2017, 22:03
by Rudolf
Hi...
Yes... it maybe a question of key, all scores are 1.
Thanks for answers... btw, I use SELECT * .