belubelu Posts: 38Questions: 14Answers: 0

I have a table with messages sent to users. Many of the messages are the same with the only difference, that they have been sent to other user_ids. Messges that are the same have the the same message_group_id. So I would like to show only messages with different message_group_ids in the table. Is there a way to do something like "SELECT DISTINCT" in editor?



  • allanallan Posts: 52,231Questions: 1Answers: 7,951 Site admin

    I'm afraid there isn't, because if you attempted to edit a row, they must already be distinct, otherwise multiple rows might be edited. Normally the primary key is the field that makes them distinct.

    Do you want to have them as editable, or just view only here?


  • belubelu Posts: 38Questions: 14Answers: 0

    ok - that makes sense...
    It would be fine to have it for view only...

  • rf1234rf1234 Posts: 1,578Questions: 51Answers: 216

    @belu wrote: "It would be fine to have it for view only..."

    Here is how I did SELECT DISTINCT with PHP and the Editor "postGet" Event:

    ->on( 'postGet', function ( $e, &$data, $id ){ 
       $data = array_values(array_unique($data, SORT_REGULAR));

    make sure you use &$data so that it gets passed by reference and can be manipulated. Just passing $data won't work because you would only be manipulating a copy of the data returned to the client.

Sign In or Register to comment.