phpmysqlsqlbuilder

Returning all the data ignoring set year limit in SQL query


I have written the following query to return all the leaves that an employee has taken.

What it should do is return values that lie in the current year and ignore the rest.

What it is doing is that it returns all the values in the table including values that pertain to previous years.

$sqlBuilder = new SQLQBuilder();

    $arrFields[0] = '`leave_date`';
    $arrFields[1] = '`leave_status`';

    $arrTable = "`leave_table`";

    $selectConditions[1] = "`employee_id` = '".$employeeId."'";
    $selectConditions[2] = "`leave_date` >= '".date('Y')."-01-01'";

    $query = $sqlBuilder->simpleSelect($arrTable, $arrFields, $selectConditions, $arrFields[0], 'ASC');

    $dbConnection = new DMLFunctions();

    $result = $dbConnection -> executeQuery($query);

    $leaveArr = $this->_buildObjArr($result);

    return $leaveArr;

Can anyone figure out what I'm doing wrong here?


Solution

  • This is simple

    $selectConditions[2] = "year(`leave_date`) = year(now())";