Send an Email in Kohana
Send an email in Kohana using the built in email class(module). In this case we are using a html email view and passing in a variable and then passing it over to the email handler.
$view = View::factory('/path/to/view');
$view->vars = "If you want to pass variables to your view";
$email = Email::factory()
->subject("Email Subject")
->to('to@email.com')
->from('no-reply@email.com', "Sender Name")
->message($view, 'text/html')
->send();
Directory File Count from Command Line
To quickly get a count of the number of files in a directory:
ls -1 targetdir | wc -l
Kohana requests from the Command Line
Kohana 3.2 has support for cli (command line interface), and can be used like this:
php -q /path/to/kohana/site/index.php --uri=cron/update_demo_data
This example assumes there is a Controller_Cron with an action_update_demo_data()
To set this up as a cron job, edit the crontab with something like this using the desired time settings
1 0 * * * /usr/bin/php -q /path/to/kohana/site/index.php --uri=cron/update_demo_data`
This example runs every day at 12:01am
In cases like t...
Calculate number of days between 2 dates in php
$days = (strtotime("2005-11-20") - strtotime(date("Y-m-d"))) / (60 * 60 * 24);
Adding Days to Dates in MySQL
To quickly add a day or days to a timestamp field in mysql, you can run a query like this:
UPDATE events SET date_starts = DATE_ADD(date_starts,INTERVAL 14 DAY) WHERE event_id = 3;