Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL select for friendships table in cometchat
    text
    copied!<p>Im beginner in sql soo i have big problem with this "big" select for friends table in cometchat. Can somebody write it for me.</p> <p>Cometchat is configured for friends table :</p> <pre><code>friends toid fromid id 2 1 id 1 2 </code></pre> <p>and sql select for it:</p> <pre><code>$sql = ("select DISTINCT ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." userid, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_NAME." username, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_LASTACTIVITY." lastactivity, ".DB_AVATARFIELD." avatar, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." link, cometchat_status.message, cometchat_status.status from ".TABLE_PREFIX."friends join ".TABLE_PREFIX.DB_USERTABLE." on ".TABLE_PREFIX."friends.toid = ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." left join cometchat_status on ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." = cometchat_status.userid ".DB_AVATARTABLE." where ".TABLE_PREFIX."friends.fromid = '".mysql_real_escape_string($userid)."' order by username asc"); return &amp;sql; </code></pre> <p>My Rails app have friendships table :</p> <pre><code>friendships user_id friend_id id 1 2 id 2 1 </code></pre> <p>When i just change order it does not work. I think that this is to hard for me right now. In rails i just check which friendship has a user_id of my profile and i show it friend_is as a friend.</p> <p>THis is generated SQL for standard cometchat settings with friend table:</p> <pre><code>select DISTINCT users.id userid, users.name username, users.current_sign_in_at lastactivity, users.id avatar, users.id link, cometchat_status.message, cometchat_status.status from friends join users on friends.toid = users.id left join cometchat_status on users.id = cometchat_status.userid where friends.fromid = '10' order by username asc </code></pre> <p>i try to change table from friends to my fiendships and toid (on friend_id) and formid( on user_id) and and vice versa but still it doesnt work and i do not get friends list.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload