Hi,
I try for several hours to specify a CDbCriteria for getting entrys with the same value.
I want have something like this:
[sql]SELECT * FROM forum_post
INNER JOIN user_gallery
ON forum_post.user_id = user_gallery.user_id;[/sql]
I tried to do it with this code:
$loadid = Yii::app()->user->id;
$criteria = new CDbCriteria;
$criteria -> condition = ("user_id=$loadid");
$data = UserGallery::model() -> findAll($criteria);
$arr = array();
foreach ($data as $userGallery) {
if($userGallery->uploaded_picture!=NULL) {
$arr[]= $userGallery->uploaded_picture;
}
}
My table structure is:
user_gallery table:
[xml]-----------------------------------
|id | user_id | image | pro_pic |
|1 | 1 | Null | new.jpg |
|2 | 1 | 1.jpg | NULL |
|3 | 1 | new.gif| NULL |
-----------------------------------[/xml]
forum_post table:
[xml]
|id | user_id | ststus | photo_id |
|1 | 1 | hello! | NULL |
|2 | 1 | NULL | 2 |
|3 | 1 | NULL | 3 |
-----------------------------------[/xml]
Now i want to get the profile picture of user who posted the post in the forum_post table.
Now I’m getting current user_id. I want to get all the user_id’s of user_gallery table… Please help me.