I tested the code below it works fine on phpmyadmin
SELECT registered_user_tbl.username, follow.follower_id FROM registered_user_tbl
INNER JOIN follow
ON follow.follower_id= 5 and registered_user_tbl.user_id= 5
I now want to implement the array version on my pdo project but it is not working kindly check and review query below
$this->db->select("SELECT registered_user_tbl.username, follow.follower_id FROM registered_user_tbl
INNER JOIN follow
ON follow.follower_id= :fid and registered_user_tbl.user_id= :fid",
(":fid" =>$user));
The 2nd parameter to your select()
method should probably be an array so the round brackets are incorrect, for your data parameters.
And you cannot reuse :fid
twice in the parameter substitution.
So try this
$this->db->select(
"SELECT registered_user_tbl.username, follow.follower_id
FROM registered_user_tbl
INNER JOIN follow ON follow.follower_id= :fid1
and registered_user_tbl.user_id= :fid2",
[":fid1" =>$user, ":fid2" =>$user]
);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.