Welcome Guest, Not a member yet? Register   Sign In
friends and users
#2

You mentioned you receive an error and I don't see any mention of the error. So, let's look at what you have. Your query builder doesn't look correct to me. I believe your query ends up like this:

Code:
SELECT * FROM user_login
JOIN user_login ON users_login.id = friends.user_id
JOIN user_login ON users_login.id = friends.friend_id
WHERE id = $user_id AND id = $friend_id

There are several things wrong with this. You are joining the same table without giving it an alias, so the columns will be ambigious if the database even allows it. On top of that, your ON statement references users_login instead of user_login or vice versa. I also see no join for a friends table. Then your WHERE clause is saying the ID has to be the $user_id AND the $friend_id. This query simply will not work. Without knowing your table structure, it is difficult for people to help out.

One thing you can do to troubleshoot queries is instead of calling get(), you can do the following:
PHP Code:
$sql $this->db->get_compiled_select();
echo 
$sql

This will display the actual query that CodeIgniter has compiled. You can run it directly against your database to see more specific results.
Reply


Messages In This Thread
friends and users - by anmol - 04-12-2017, 11:21 AM
RE: friends and users - by xenomorph1030 - 04-14-2017, 05:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB