getCollectionFromDb ignores ORDER BY?
Posted: 22 April 2023, 17:53
Hi,
I'm trying to get the data from server and give it back to the js in the getAllDatas function, but when the data gets to the js it's always sorted using the id not the value that was given to the SQL request
This is my code:
in JS I have this code:
Why isn't my data sorted (now it gets sorted by the id)
Thanks!
I'm trying to get the data from server and give it back to the js in the getAllDatas function, but when the data gets to the js it's always sorted using the id not the value that was given to the SQL request
This is my code:
Code: Select all
$sql = "SELECT planet_id id, is_hidden hidden, position pos FROM planet ORDER BY pos ASC";
$result['planets'] = self::getCollectionFromDb( $sql );Code: Select all
for (var i in this.gamedatas.planets)
{
var p = this.gamedatas.planets[i];
this.showPlanetOnTable(p.id, p.hidden, p.pos, this.gamedatas.planets_extra[p.id].css_name);
}
showPlanetOnTable : function(planet_id, is_hidden, pos, css_name)
{
console.log('id: '+planet_id+' hidden: '+is_hidden+' pos: '+pos+' css_name: '+css_name);
dojo.place(this.format_block('jstpl_planet',
{
planet_css : css_name,
planet_id : planet_id
}), 'planets');
},
Thanks!