I am trying to develop a game to learn foreign vocabulary.
When the page loads I use xpdo to fetch all the words from the database, the words are sorted by ‘id’ :
$c = $modx->newQuery( DOODLECLASS ); $c->select( $modx->getSelectColumns( DOODLECLASS, DOODLECLASS ) ); $c->sortby( 'id', 'ASC' ); $c->prepare(); $c->stmt->execute();
In another sql table I have a field where the scores for each word are recorded as JSON. After decoding this JSON I have a php array containing word ids and their scores.
In this example we can see word ‘0’ has a score of 624.
$words = [ '0' => 624, '1' => 216, ... , '1000' => 546 ]
Now I am tying to adapt the xpdo request in order to sort the words by their scores.
I think in order to sort the words by their scores I will have to make a jointure between the words table and the php array containing the scores.
Is it possible with xpdo to make a join with the data in my php array? Any hint to help me please?