public function get_user_profile_data($username, $user_fields = NULL) { if ($user_fields == NULL) { $user_fields = 'user_id, user_fullname, user_username, user_email, user_city, user_state, user_country, user_location, user_latitude, user_longitude, user_dob, user_gender, user_relationship_status, user_about, user_tagline, user_profile_picture, user_facebook_id, user_languages_known'; } $model = new Common_model(); $records = $model->fetchSelectedData($user_fields, TABLE_USERS, array('user_username' => $username)); if (!empty($records)) { $records = $records[0]; } // to fetch trips posted by the user $trips_posted_records = $model->fetchSelectedData('post_id, post_url_key, post_published', TABLE_POSTS, array('post_user_id' => $records['user_id']), 'post_id', 'DESC'); $records['trips_posted'] = $trips_posted_records; // to fetch the trips owner has joined $records['trips_joined'] = $this->get_joined_trips($username); // to fetch user's wishlist $wishlist_records = $model->getAllDataFromJoin('post_url_key', TABLE_WISHLIST, array(TABLE_POSTS => 'post_id = wishlist_post_id'), 'LEFT', array('wishlist_status' => '1', 'post_published' => '1', 'wishlist_user_id' => $records['user_id']), 'wishlist_id', 'DESC'); $records['my_wishlist'] = $wishlist_records; return $records; }