EVOLUTION-NINJA
Edit File: Update.php
<?php namespace App\Controllers; class Update extends BaseController{ public function __construct() { $this->db = \Config\Database::connect(); date_default_timezone_set('Asia/Kolkata'); } public function update_adm_financial_year(){ $builder = $this->db->table('create_project'); $builder->select('adm_date,id'); $query = $builder->get(); $role = $query->getResultArray(); foreach ($role as $doc) { $d = $doc['adm_date']; // 2025-11-10 $arr = explode("-",$doc['adm_date']); if(count($arr) == 3){ $year = $arr[0]; $month = $arr[1]; $f_year = ''; if($month <= 3){ $f_year = ($year - 1)."-".substr((string)$year, -2); } else{ $year_1 = ($year + 1); $f_year = $year."-".substr((string)$year_1, -2); } $builder = $this->db->table('create_project'); $adm_financial_year = [ 'adm_financial_year' => $f_year, ]; $builder->where('id', $doc['id']); // specify the condition $update = $builder->update($adm_financial_year); // perform the update } } } }