lundi 29 juin 2015

Neo4j PHP returning results at the same order as the where

I have nodes with the label "Campaign". I'm getting them each time in a different order.

So after I query to the DB, I have an array with Campaigns objects.

After that, I'm sending them into another function in the db.

MATCH (campaign:Campaign)
                 where campaign.id="1433855846340" or campaign.id="1433855948013" or campaign.id="1433856017523" or campaign.id="1433856146618" or campaign.id="1433856170282" or campaign.id="1433856364138" or campaign.id="1433856901298" or campaign.id="1433857169469" or campaign.id="1433857216853" or campaign.id="1433873093289" or campaign.id="1433873178949" or campaign.id="1433926766014"
                with campaign optional match campaign<-[:TAKEN_IN]-(picture:Picture) with campaign, collect(picture) as pictures
                with pictures[toInt(rand()*size(pictures))] as picture,campaign
                optional match picture-[:UPLOADED_TO]->(facebookPicture:FacebookPicture)
                RETURN picture.source as coverPicture,campaign.id

Basically all I need, is to return the results at the same order as the where clause. How can I do that without knowing if the campaigns were got from the DB, in

DESC

, for example/

Aucun commentaire:

Enregistrer un commentaire