dbtry($sql); if ($this->chk4cron('vucc_grid_file') == 0) { $data = array( array( 'id' => 'vucc_grid_file', 'enabled' => '0', 'status' => 'enabled', 'description' => 'Update TQSL VUCC Grids file', 'function' => 'index.php/update/update_vucc_grids', 'expression' => '0 0 1 * *', 'last_run' => null, 'next_run' => null )); $this->db->insert_batch('cron', $data); } } public function down() { $sql = "DROP TABLE IF EXISTS vuccgrids;"; $this->dbtry($sql); if ($this->chk4cron('vucc_grid_file') > 0) { $this->db->query("delete from cron where id='vucc_grid_file'"); } } function dbtry($what) { try { $this->db->query($what); } catch (Exception $e) { log_message("error", "Something gone wrong while altering a table: ".$e." // Executing: ".$this->db->last_query()); } } function chk4cron($cronkey) { $query = $this->db->query("select count(id) as cid from cron where id=?",$cronkey); $row = $query->row(); return $row->cid ?? 0; } }