I have tried them all,... nothing seems working
// $parent_id = $this->VideoFavorite- >findById($user['VideoFavorite']['parent_id']); // $parent_id = $this->User->field('id',array('username'=> $username)); // $parent_id = $this->Video->field('id',array('user_id'=> $user_id)); $parent_id = $this->VideoFavorite->field('id',array('parent_id'=> $parent_id)); // $parent_id = $this->Video->field(user_id); Please help... Thanks On Dec 22, 5:56 pm, "chris...@yahoo.com" <chris...@yahoo.com> wrote: > Hi Amit, thanks again,... > > no there is no unique username, this is a social network site with > lots of users ;) I guess,... this still in construction... > and I'm building and adding Users Video Favorites Section, Group > Favorites, Blog Favorites etc... > And I think I have to call user_id or parent_id either from Video or > VideoFavorite tables. > > I already set it up VideoFavorite parent_id value to = Video user_id > > function set_favorites($id) > { > > if(!($user = $this->User->findById($this->user['id']))) > { > $this->flash('error', ucfirst(i18n::translate('user not > found'))); > $this->redirect('/'); > } > else > { > if(!($video = $this->Video->findById($id))) > { > $this->flash('error', ucfirst(i18n::translate('video not > found'))); > $this->redirect('/'); > } > else > { > $favorites['VideoFavorite']['video_id'] = $video['Video'] > ['id']; > $favorites['VideoFavorite']['parent_id'] = $video['Video'] > ['user_id']; > $favorites['VideoFavorite']['category_id'] = $video['Video'] > ['category_id']; > $favorites['VideoFavorite']['privacy'] = $video['Video'] > ['privacy']; > $favorites['VideoFavorite']['created'] = $video['Video'] > ['created']; > $favorites['VideoFavorite']['user_id'] = $user['User']['id']; > > if(!$this->VideoFavorite->save($favorites)) > { > $this->flash('error', > ucfirst(i18n::translate('unexpected'))); > } > else > { > $this->flash('valid', ucfirst(i18n::translate('favorites > added'))); > } > > $this->redirect('/videos/favorites/' . $user['User'] > ['username']); > } > } > } > > Thanks > Chris > > On Dec 22, 5:26 pm, Amit Rawat <rawatami...@gmail.com> wrote: > > > > > > > > > Hi, > > > Is your username unique? > > > if yes then you can use this > > > $parent_id=$this->User->field('id',array('username'=>$username)); > > > Enjoy > > > On Thu, Dec 23, 2010 at 6:48 AM, chris...@yahoo.com > > <chris...@yahoo.com>wrote: > > > > Hi Amit, thank you for your help. But it didn't work. I may, as well > > > post the whole function here. This is a favorites section that I'm > > > trying to create. All I'm trying to do,... is call parent_id so I can > > > link it to original video user username(profile) and video from view > > > page favorites.ctp. If you have a time can you please take peak at > > > >http://www.zippopeople.com > > > and this is a testing URL > > > > Thank Yo..All ! > > > > function favorites($username = null) > > > { > > > > if($username == 'unknown') > > > $this->authorize(); > > > > if(!($user = $this->User->findByUsername($username))) > > > { > > > $this->flash('error', ucfirst(i18n::translate('user not > > > found'))); > > > $this->redirect('/'); > > > } > > > > else > > > { > > > $filter = $this->params['pass']; > > > unset($filter['page']); > > > unset($filter['sort']); > > > unset($filter['direction']); > > > $this->set('url_options', $filter); > > > > $parent_id = $this->Video->field('user_id'); > > > > $this->menu->setSelected('/videos/index/' . $user['User'] > > > ['username']); > > > $this- > > > >set_title(ucfirst(Inflector::pluralize(i18n::translate('favorite > > > videos'))) . ' : ' . $user['User']['firstname'] . ' ' . $user['User'] > > > ['lastname']); > > > > $scope = array('VideoFavorite.user_id' => $user['User']['id']); > > > if(array_key_exists('date', $this->params['pass'])) > > > $scope[] = 'DATE(VideoFavorite.created) = \'' . strftime('%Y- > > > %m-%d', strtotime($this->params['pass']['date'])) . '\''; > > > > if($this->is_user()) > > > $is_friend = in_array($this->user['id'], $this->Friend- > > > >myFriends($user['User']['id'])); > > > else > > > $is_friend = false; > > > > if($this->is_user() && $this->user['id'] == $user['User']['id']) > > > { > > > // the owner has no restriction > > > } > > > elseif($this->is_user() && $is_friend) > > > { > > > $scope[] = 'VideoFavorite.privacy <= ' . > > > array_search('friend', Configure::read('Site.privacy')); > > > } > > > else > > > { > > > $scope[] = 'VideoFavorite.privacy <= ' . > > > array_search('public', Configure::read('Site.privacy')); > > > } > > > > $videos = $this->paginate('VideoFavorite', $scope); > > > > $this->set('videos', $videos); > > > $this->set('dates', $dates = $this->VideoFavorite->query('SELECT > > > DATE(created) AS date, COUNT(*) AS videos FROM fociki_video_favorites > > > WHERE user_id = ' . $user['User']['id'] . ' GROUP BY DATE(created) > > > ORDER BY created DESC')); > > > $videos_count = 0; > > > foreach($dates as $date) > > > $videos_count += $date[0]['videos']; > > > $this->set('videos_count', $videos_count); > > > > $this->set('user_obj', $user); > > > $this->set('parent', $parent_id); > > > > $this->set('friends', $this->Friend->find('all', array('limit' > > > => 12, 'conditions' => array('Friend.user_id' => $user['User']['id']), > > > 'order' => array('Friend.created' => 'DESC')))); > > > > } > > > > } > > > > and here is my tables: > > > > videos table > > > id int(11) UNSIGNED No auto_increment > > > user_id int(11) Yes NULL > > > category_id int(11) Yes NULL > > > name varchar(120) latin1_swedish_ci No > > > description text latin1_swedish_ci Yes > > > NULL > > > embed_code text latin1_swedish_ci Yes > > > NULL > > > video_thumb text latin1_swedish_ci Yes > > > NULL > > > views int(11) No 0 > > > comments int(11) No 0 > > > last_comment datetime Yes NULL > > > promo_status int(11) No 0 > > > privacy int(1) UNSIGNED No 0 > > > created datetime No 0000-00-00 00:00:00 > > > > video_favorites table > > > id int(11) UNSIGNED No > > > auto_increment > > > video_id int(11) UNSIGNED No 0 > > > user_id int(11) Yes NULL > > > category_id int(11) Yes NULL > > > privacy int(1) UNSIGNED No 0 > > > created datetime No 0000-00-00 00:00:00 > > > parent_id int(11) Yes NULL > > > > Thanks again, any help is appreciated !!! > > > Chris > > > > On Dec 22, 4:20 pm, Amit Rawat <rawatami...@gmail.com> wrote: > > > > Hi Chris, > > > > > Use find field > > > > > $parent_id = $this->Video->field('user_id',array('your condition goes > > > > here')) > > > > > enjoy, > > > > > Amit > > > > > On Thu, Dec 23, 2010 at 3:41 AM, chris...@yahoo.com <chris...@yahoo.com > > > >wrote: > > > > > > Hi All,... sound stupid but I have to ask... > > > > > I want to call user_id from Video table in to $parent_id variable in > > > > > my controller in order to display and link to parent user username, > > > > > video in ..."Favorites" section. And how do I do that...? Please > > > > > help... > > > > > > $parent_id = $this->Video ??? > > > > > > thanks > > > > > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp > > > others > > > > > with their CakePHP related questions. > > > > > > You received this message because you are subscribed to the Google > > > Groups > > > > > "CakePHP" group. > > > > > To post to this group, send email to cake-php@googlegroups.com > > > > > To unsubscribe from this group, send email to > > > > > cake-php+unsubscr...@googlegroups.com<cake-php%2bunsubscr...@googlegroups.c > > > > > om> > > > <cake-php%2bunsubscr...@googlegroups.c om>For more options, visit this > > > group at > > > > >http://groups.google.com/group/cake-php?hl=en > > > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others > > > with their CakePHP related questions. > > > > You received this message because you are subscribed to the Google Groups > > > "CakePHP" group. > > > To post to this group, send email to cake-php@googlegroups.com > > > To unsubscribe from this group, send email to > > > cake-php+unsubscr...@googlegroups.com<cake-php%2bunsubscr...@googlegroups.c > > > om>For more options, visit this group at > > >http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en