FreiChat related discussions
SOLVED: Order the users by nickname (name)

Hi

I am using the Joomla driver and I need to change the query to order the online users by nickname (name).

I know that I need to change the query in the Joomla.php file adding an ORDER BY. However I cannot understand in which SQL query I need to put the ORDER BY name.

Thanks in advance!

Hi I am using the Joomla driver and I need to change the query to order the online users by nickname (name). I know that I need to change the query in the Joomla.php file adding an ORDER BY. However I cannot understand in which SQL query I need to put the ORDER BY name. Thanks in advance!
edited Dec 6 '15 at 8:15 am

Found it.
In order to make order by username you need to change two queries in the freichat/server/drivers/base.php file.

public function get_guests() {

        $query = "SELECT DISTINCT status_mesg,username,session_id,status,guest,in_room
                   FROM frei_session
                  WHERE time>" . $this->online_time2 . "
                   AND session_id<>" . $_SESSION[$this->uid . 'usr_ses_id'] . "
                   AND status<>2
                   AND status<>0
           ORDER BY username ASC";
//echo $query;

        $list = $this->db->query($query)->fetchAll();
        return $list;
    }
public function get_users() {

        $query = "SELECT DISTINCT status_mesg,username,session_id,status,guest,in_room
                   FROM frei_session
                  WHERE time>" . $this->online_time2 . "
                   AND session_id<>" . $_SESSION[$this->uid . 'usr_ses_id'] . "
                   AND guest=0
                   AND status<>2
                   AND status<>0
           ORDER BY username ASC";

        $list = $this->db->query($query)->fetchAll();

        return $list;
    }

However even if I forced to make the order ASC...It still makes it DESC!
I really don't have a clue why this is happens.

Any idea for the codologic team?

Thanks!

Found it. In order to make order by username you need to change two queries in the freichat/server/drivers/base.php file. ```` public function get_guests() { $query = &quot;SELECT DISTINCT status_mesg,username,session_id,status,guest,in_room FROM frei_session WHERE time&amp;gt;&quot; . $this-&amp;gt;online_time2 . &quot; AND session_id&amp;lt;&amp;gt;&quot; . $_SESSION[$this-&amp;gt;uid . &#039;usr_ses_id&#039;] . &quot; AND status&amp;lt;&amp;gt;2 AND status&amp;lt;&amp;gt;0 ORDER BY username ASC&quot;; //echo $query; $list = $this-&amp;gt;db-&amp;gt;query($query)-&amp;gt;fetchAll(); return $list; } ```` ```` public function get_users() { $query = &quot;SELECT DISTINCT status_mesg,username,session_id,status,guest,in_room FROM frei_session WHERE time&amp;gt;&quot; . $this-&amp;gt;online_time2 . &quot; AND session_id&amp;lt;&amp;gt;&quot; . $_SESSION[$this-&amp;gt;uid . &#039;usr_ses_id&#039;] . &quot; AND guest=0 AND status&amp;lt;&amp;gt;2 AND status&amp;lt;&amp;gt;0 ORDER BY username ASC&quot;; $list = $this-&amp;gt;db-&amp;gt;query($query)-&amp;gt;fetchAll(); return $list; } ```` However even if I forced to make the order ASC...It still makes it DESC! I really don&#039;t have a clue why this is happens. Any idea for the codologic team? Thanks!

Why not try making it ORDER BY username DESC.

It worked in our localhost.

Why not try making it ORDER BY username DESC. It worked in our localhost.

Hi

I will try and I will let u know.
However to be honest it doesn't make sense to me..;-)
Thanks!

Hi I will try and I will let u know. However to be honest it doesn&#039;t make sense to me..;-) Thanks!
236
4
2
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft