Wednesday, December 19, 2012

Re: updating table field by date

thank you jsunquist,... 
I'll try,... 


On Wednesday, December 19, 2012 12:45:28 PM UTC-8, jsundquist wrote:
Chris,

Just to help you out instead of the giant mktime string you have you can also use strtotime().  Within the function you can simply do strtotime('+30 days') which will do the same thing as above.


On Wed, Dec 19, 2012 at 2:39 PM, Chris <chri...@yahoo.com> wrote:
hi cricket,.... thank you for your response 
I have another approach to it,... on the click to advertising banner and/or link thru function (link goes thru function), and checks and compare  "featured_end" date with today's date,... and if it less than today's date it resets table. 
here is the function,... just in case anyone needs it: 

  function featured($id = null)
  {
    if(!($dba = $this->Dba->findById($id)))
    {
      $this->flash('error', ucfirst(i18n::translate('dba not found')));
      $this->redirect('/not_found');
    }
    elseif(!($user = $this->User->findById($dba['Dba']['user_id'])))
    {
      $this->flash('error', ucfirst(i18n::translate('user not found')));
      $this->redirect('/not_found');
    }
    else
    {
$today = date('Y-m-d H:i:s');

    if($dba['Dba']['featured_end'] <= $today)
    {
      $dba['Dba']['featured'] = 0;
      $dba['Dba']['featured_start'] = NULL;
      $dba['Dba']['featured_end'] = NULL;

      $this->Dba->save($dba);

      $this->redirect('/');

    }
        $this->redirect('/dbas/view/' . $dba['Dba']['id']);
    }    
 }




On Wednesday, December 19, 2012 11:11:07 AM UTC-8, cricket wrote:
Create a shell task to fetch all records with featured == 1 and
end_date in the past. Run a cron job at midnight to call it.

On Wed, Dec 19, 2012 at 6:22 AM, Chris <chri...@yahoo.com> wrote:
> hi guys,... can anyone help please
>
> I'm building promotional advertising feature on a site,...
> and have a table fields: "featured_start" once the user is call the function
> and "featured_end" after 30 days:
>
> $dba['Dba']['featured'] = 1;
> $dba['Dba']['featured_start'] = date('Y-m-d H:i:s');
> $after_30 = mktime(date("H"), date("i"), date("s"), date("m"), date("d")+30,
> date("y"));
> $dba['Dba']['featured_end'] = date('Y-m-d H:i:s', $after_30);
>
> now I want to set $dba['Dba']['featured'] = 0; after 30 days,
> and reset "featured_start" and "featured_end" to NULL
> so the promotion can stop,...
>
> how can I this,...?
>
> thanks in advance
> chris
>
>
>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake...@googlegroups.com.
> To unsubscribe from this group, send email to
> cake-php+u...@googlegroups.com.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake...@googlegroups.com.
To unsubscribe from this group, send email to cake-php+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
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+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: