Created
June 18, 2014 15:20
-
-
Save Tapha/009f0bb07eff4fef13d5 to your computer and use it in GitHub Desktop.
Createdate controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
| class Createdate extends CI_Controller { | |
| function __construct() | |
| { | |
| parent::__construct(); | |
| $this->load->library('ion_auth'); | |
| $this->load->model('Users'); | |
| $this->load->model('Podcast'); | |
| } | |
| public function create_dates() | |
| { | |
| //check for user type to direct to right backend. | |
| //redirect them to the login page | |
| $today = date("Y-m-d"); | |
| $this->db->select_max('id'); | |
| $query = $this->db->get('lut_dates'); | |
| $id = $query->result()[0]->id; | |
| $q = $this->db->get_where('lut_dates', array('id' => $id), 1); | |
| $last = $q->result()[0]->date; | |
| if ($today == $last) | |
| { | |
| $tomo = new DateTime($today.' + 1 day'); | |
| $tomo = $tomo->format('Y-m-d'); | |
| $data_1 = array( | |
| 'date'=> $tomo | |
| ); | |
| $this->db->insert('lut_dates', $data_1); | |
| for ($i = 1; $i <= 365; $i++) { | |
| $tomo = new DateTime($tomo.' + 1 day'); | |
| $tomo = $tomo->format('Y-m-d'); | |
| $data_2 = array( | |
| 'date'=> $tomo | |
| ); | |
| $this->db->insert('lut_dates', $data_2); | |
| //echo $tomo.'<br>'; | |
| } | |
| } | |
| else | |
| { | |
| echo 'na - not today mate.'; | |
| } | |
| } | |
| } | |
| /* End of file */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment