Re: call in to variables...

2010-12-23 Thread chris...@yahoo.com
Hi cricket, Thank You for your reply,

speaking of "unique usernames"... in fact yes, they are all unique.
i'm not quite understud what Amit meant to be,... yes they are all
unique, and each user has its own Videos, Groups, Blogs, Profile,
Business Profile, etc... and in order to favorite let say I (user1)
want to favorite video that you (user2) have post it in from youtube
or google and have favorite section so I can access with no time. the
clear picture of this,... if its not to much trouble could you please
access http://www.zippopeople.com and please signup to see your
favorite section in My Videos, My Groups, ... this is just a testing
URL and all records will be deleted after all... here is my ../views/
videos/favorites.ctp file, and in order to link to that ORIGINAL VIDEO
that have been posted from your favorites you need to have a some
unique string (i name it $parent['User']['username']) other from
($user_obj['User']['username']) where in my case "user_obj" is the
User1 and "parent" is User2. and I have to link it to ORIGINAL video
show page. here is my favorites.ctp file








  link($photoShow->buddy($user_obj, array('height'
=> 36, 'width' => 36)), '/profile/' . $user_obj['User']['username'],
false, false, false) ?>




  

  
  : link($user_obj['User']['firstname'] . ' ' .
$user_obj['User']['lastname'], '/profile/' . $user_obj['User']
['username'], array('style' => 'color: #00;')) ?>

  


  


   : 
   
   : 
   


  





 

 

link(ucfirst(__('ALL VIDEOS', true)), '/
videos' , array('style' => 'color: #00;')) ?>
 


 
 is_authorized($user_obj['User']['id'])): ?>
link(ucfirst(__('my favorites', true)) . ' - ' .
$user_obj['User']['video_favorites'], '/videos/favorites/' .
$user_obj['User']['username']) ?>
  |  

  link(ucfirst(Inflector::pluralize(__('video',
true))) . ' ' . $user_obj['User']['firstname'] . ' ' .
$user_obj['User']['lastname'] . ' - ' . $user_obj['User']['videos'], '/
videos/index/' . $user_obj['User']['username']) ?>


 







:


sort(__('added date', true), 'created',
array('model' => 'VideoFavorite', 'escape' => false, 'url' =>
am($url_options, array('direction' => 'desc', 'page' => 1)), 'class'
=> $application->paginator_order() == 'created' ? 'selected' : '')) ?>
 -
sort(__('alphabetically', true), 'name',
array('model' => 'VideoFavorite', 'direction' => 'desc', 'escape' =>
false, 'url' => am($url_options, array('direction' => 'asc', 'page' =>
1)), 'class' => $application->paginator_order() == 'name' ?
'selected' : '')) ?>
     

  link(ucfirst(__('videos', true)) . ' - ' .
$this->params['paging']['VideoFavorite']['count'], '/videos/index/' .
$user_obj['User']['username'], array('class' => 'photos')) ?>
   

  params['pass'])): ?>
  link(ucfirst(__('added date', true)) . ' : ' .
$application->daysAgo($time, strftime('%Y-%m-%d', strtotime($this-
>params['pass']['date']))), '/videos/favorites/' . $user_obj['User']
['username'] . '/date:' . $this->params['pass']['date'], array('class'
=> 'calendar')) ?>
  
  link(ucfirst(__('added date', true)) . ' : ' .
__('all', true), '/videos/favorites/' . $user_obj['User']['username'],
array('class' => 'calendar')) ?>
  

  

  
link(__('all', true) . ' - ' .
$videos_count, '/videos/index/' . $user_obj['User']['username']) ?>

link($application->daysAgo($time,
current(current($date))) . ' - ' . $date[0]['videos'], $paginator-
>url(am($url_options, array('date' => $time->format('j.n.Y',
current(current($date), true)) ?>
 
  







 is_authorized($user_obj['User']['id'])): ?>
  

   link(ucfirst(__('upload Videos', true)), '/
videoupload', array('class' => 'photos'), false, false, false) ?>
|
 link(ucfirst(__('manage Videos', true)), '/videos/
manage/' . $user_obj['User']['id'], array('class' => 'edit'), false,
false) ?>

  









  




link($html->image("myplay.jpg", array('height' =>
84, 'width' => 120)),'/videos/show/'.$user_obj['User']['username'].'/'.
$video['Video']['id'],array('escape'=>false))?>


link($html->image($video['Video']['video_thumb'],
array('height' => 84, 'width' => 120)),'/videos/show/'.
$user_obj['User']['username'].'/'.$video['Video']
['id'],array('escape'=>false))?>









: 
cut($video['Video']['name'], 60) ?>





: 
cut($video['Video']['description'], 100) ?>




  

: 
link($video['VideoCategory']['name'], '/videos/' .
$video['VideoCategory']['name']) ?>

 : 
link($parent['User']['username'], '/profile/' .
$parent['User']['username']) ?>





: 

   |   
link(ucfirst(Inflector::pluralize(__('comment',
true))) . ' - ' . $video['Video']['comments'], '/videos/show/' .
$user_obj['User']['username'] . '/' . $video['Video']['id']) 

Re: call in to variables...

2010-12-23 Thread cricket
On Wed, Dec 22, 2010 at 8:56 PM, chris...@yahoo.com  wrote:
>
> no there is no unique username, this is a social network site with
> lots of users ;) I guess,... this still in construction...

If username is not unique your favorites action will never work
properly as it's only param is $username. You'll either need to ensure
that usernames are unique across your DB or use something else with
which to get a particular user's favorites.

I haven't gone through all of your code (frankly, it looks like it
would benefit from a careful re-write, especially moving quite a lot
of it to a model) but, in order to use model::field() you first must
set the model's id. The point of field() is to get the column value
for a particular row. If the model's id is not set, you can't query
that row.

I think $parent_id isn't a good choice for variable name here, as
you're not dealing with the parent Video of another Video. I assume
that it's the User that created the Video, but I'm unsure.

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


Re: call in to variables...

2010-12-22 Thread chris...@yahoo.com
and here what I have in models: I roow knoow knoow what's right what's
wrong anymore...

 VALID_NOT_EMPTY,
'user_id' => VALID_NOT_EMPTY,
'category_id' => VALID_NOT_EMPTY,
'description' => VALID_NOT_EMPTY,
'embed_code' => VALID_NOT_EMPTY
);

var $belongsTo = array(
'VideoCategory' => array(
'className' => 'VideoCategory',
'foreignKey'=> 'category_id'
),
'User'
);

var $hasMany = array(
'VideoComment' => array(
'className' => 'VideoComment',
'foreignKey'=> 'video_id'
),
'VideoFavorite' => array(
'className' => 'VideoFavorite',
'foreignKey'=> 'video_id'
)
);

   function afterDelete()
   {
 $this->loadModels('VideoComment');

 foreach($this->VideoComment->find('all', array('conditions' =>
array('VideoComment.video_id' => $this->id( as $video_comment)
   $this->VideoComment->delete($video_comment);
   }


}
?>

AND

 VALID_NOT_EMPTY,
'user_id' => VALID_NOT_EMPTY,
'parent_id' => VALID_NOT_EMPTY,
'category_id' => VALID_NOT_EMPTY
  );

var $belongsTo = array(
'VideoCategory' => array(
'className' => 'VideoCategory',
'foreignKey'=> 'category_id'
), 'User', 'Video'
);


var $hasMany = array(
'Video' => array(
'className' => 'Video',
'foreignKey'=> 'id'
),
'VideoCategory' => array(
'className' => 'VideoCategory',
'foreignKey'=> 'id'
)

);

  function afterDelete()
  {
  }
}
?>

MUCHO THANKS !!!
Chris


On Dec 22, 5:56 pm, "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  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 
> > 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(

Re: call in to variables...

2010-12-22 Thread chris...@yahoo.com
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"  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  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 
> > 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->

Re: call in to variables...

2010-12-22 Thread chris...@yahoo.com
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  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 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 tab

Re: call in to variables...

2010-12-22 Thread Amit Rawat
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 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) UNSIGNEDNo  auto_increment
>user_id int(11) Yes NULL
>category_id int(11) Yes NULL
>namevarchar(120)latin1_swedish_ci   No
>description textlatin1_swedish_ci   Yes NULL
>embed_code  textlatin1_swedish_ci   Yes NULL
>video_thumb textlatin1_swedish_ci   Yes NULL
>views   int(11) No  0
>commentsint(11) No  0
>last_commentdatetimeYes NULL
>promo_statusint(11) No  0
>privacy int(1)  UNSIGNEDNo  0
>created datetimeNo  -00-00 00:00:00
>
> video_favorites table
>id  int(11) UNSIGNEDNo
>  auto_increment
>video_idint(11) UNSIGNEDNo  0
>user_id int(11) Yes NULL
>category_id int(11) Yes NULL
>privacy int(1)  UNSIGNEDNo  0
>created datetimeNo  -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  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  >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 i

Re: call in to variables...

2010-12-22 Thread chris...@yahoo.com
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) UNSIGNEDNo  auto_increment
user_id int(11) Yes NULL
category_id int(11) Yes NULL
namevarchar(120)latin1_swedish_ci   No
description textlatin1_swedish_ci   Yes NULL
embed_code  textlatin1_swedish_ci   Yes NULL
video_thumb textlatin1_swedish_ci   Yes NULL
views   int(11) No  0
commentsint(11) No  0
last_commentdatetimeYes NULL
promo_statusint(11) No  0
privacy int(1)  UNSIGNEDNo  0
created datetimeNo  -00-00 00:00:00

video_favorites table
id  int(11) UNSIGNEDNo  auto_increment
video_idint(11) UNSIGNEDNo  0
user_id int(11) Yes NULL
category_id int(11) Yes NULL
privacy int(1)  UNSIGNEDNo  0
created datetimeNo  -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  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 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.organd help others
> > with their CakePHP related questions.
>
> > You received this message because you are subscribed to the Google Groups
> > 

Re: call in to variables...

2010-12-22 Thread Amit Rawat
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 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 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.comFor
>  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