FreiChat related discussions
Friend Integration

Okay so friend integration,

I have a table called social_friend
It has 3 colums:

username - friendname - friend_status

A typical call looks something like:

SELECT friendname FROM social_friend WHERE username = $_SESSION[user] AND friend_status='2'

Now keeping in mind I have a JOIN statement already going on for the avatars, it seems 2 JOIN's are needed on the get_buddies function.

I am obviously not very good at this because my attempts, fail:

Heres what I was trying:

            $query = "SELECT DISTINCT f.status_mesg,f.username,f.session_id,f.status,f.guest,f.in_room,u.email,a.username,a.friendname,a.friend_status
                   FROM frei_session AS f
                   JOIN LEFT members AS u ON f.session_id=u.Id
                   JOIN LEFT social_friend AS a ON u.username=a.username
                  WHERE f.time>" . $this->online_time2 . "
                   AND f.session_id!=" . $_SESSION[$this->uid . 'usr_ses_id'] . "
                   AND f.status!=2
                   AND f.status!=0
                   AND f.guest=0
                   AND f.username=a.username
                   AND a.friend_status=2";

This isn't working. What am I doing wrong here?

Okay so friend integration, I have a table called social_friend It has 3 colums: username - friendname - friend_status A typical call looks something like: ```` SELECT friendname FROM social_friend WHERE username = $_SESSION[user] AND friend_status='2' ```` Now keeping in mind I have a JOIN statement already going on for the avatars, it seems 2 JOIN's are needed on the get_buddies function. I am obviously not very good at this because my attempts, fail: Heres what I was trying: ```` $query = "SELECT DISTINCT f.status_mesg,f.username,f.session_id,f.status,f.guest,f.in_room,u.email,a.username,a.friendname,a.friend_status FROM frei_session AS f JOIN LEFT members AS u ON f.session_id=u.Id JOIN LEFT social_friend AS a ON u.username=a.username WHERE f.time>" . $this->online_time2 . " AND f.session_id!=" . $_SESSION[$this->uid . 'usr_ses_id'] . " AND f.status!=2 AND f.status!=0 AND f.guest=0 AND f.username=a.username AND a.friend_status=2"; ```` This isn't working. What am I doing wrong here?
edited Nov 11 '15 at 4:01 am
108
1
1
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