PDO Library Medoo descending order not working

587 Views Asked by At

i am using a library for PDO which has basic and easy syntax so everyone with basic MySQL knowledge will understand the code. I've tried running the queries with PDO (without the library i am using) but the issue persists.

$tickets = classes::$pdo->select('tickets', '*', [
                'TicketUserID' => classes::$user->data['UserID']
            ]);

            foreach($tickets as $ticket) {
                $ticket_replies = classes::$pdo->select('replies', '*', [
                    'ReplyTicketID' => $ticket['TicketID']
                ], [
                    'ORDER' => [
                        'ReplyID' => 'DESC'
                    ],
                    'GROUP' => 'ReplyTicketID'
                ]);

                foreach($ticket_replies as $reply) {
                    echo $reply['ReplyID'];
                }
            }

After running the query i am getting a correct list with all selections but in Ascending order instead of descending. I am sure that this is not an issue in the library but in my code.

Regards.

1

There are 1 best solutions below

0
On

Have you tried; ?

$tickets = classes::$pdo->select('tickets', '*', [
    'TicketUserID' => classes::$user->data['UserID']
]);

foreach($tickets as $ticket) {
    $ticket_replies = classes::$pdo->select('replies', '*', [
        'ReplyTicketID' => $ticket['TicketID'],
        'ORDER' => ['ReplyID' => 'DESC'],
        'GROUP' => 'ReplyTicketID'
    ]);

    foreach($ticket_replies as $reply) {
        echo $reply['ReplyID'];
    }
}

Because i think that your array was incorrect.