Query Logic For mysql and php

2019-09-06 09:14发布

问题:

we have this company where they work on a yearly period of april"current year" to march"next year" Im writing and excel report to pull out reports based on that period. where Jan, Feb, and march would be the next year , but I keep on getting the current year do you get me? bus_year = is the year inform Jan to Dec, but its actually April to march and year is year

I would like to know how, I could write a good logic whereby on selected months the logic would plus 1 year to the current, from instead of Jan 2013 to Jan 2014. I'm trying to brige years , and could not use unix_timestamp solely because Its just been implemented noe in the database and the is more than 5 year of data in it.

current code

 private $month_array  = array(
        '01' => "January",
        '02' => "February",
        '03' => "March",
        '04' => "April",
        '05' => "May",
        '06' => "June",
        '07' => "July",
        '08' => "August",
        '09' => "September",
        '10' => "October",
        '11' => "November",
        '12' => "December"
    );

    private $financial_year_month = array(
        '04' => '01',
        '05' => '02',
        '06' => '03',
        '07' => '04',
        '08' => '05',
        '09' => '06',
        '10' => '07',
        '11' => '08',
        '12' => '09',
        '01' => '10',
        '02' => '11',
        '03' => '12'
    );

maybe to right in in a form like this for example

04-$year, 05-year, ... , 02-($year+1), 03-($year+1)

//sql query public function get($year) { $select = $this->select(); $select->where('bus_year = ?', $year); return $this->fetchAll($select); }

Database columns Id/month/year/bus_year

Not sure how I can define and initialize year at the moment. Something like this but my current code wont take it, don't know what Im missing

if($month >= 01 && $month <= 03){ $year = $year + 1;