function get_sql_compare_and_value($compare, $value) { $sql_compare = ''; $sql_value = ''; switch ($compare) { case 0: // bool do not compare // explicitly skip adding a clause when $compare == 0 ( "--" in the GUI ) break; case 1: // bool is true $sql_compare = '!='; $sql_value = "0"; break; case 2: // bool is false $sql_compare = '='; $sql_value = "0"; break; case 40: // number do not compare // explicitly skip adding a clause when $compare == 40 ( "--" in the GUI ) break; case 41: // number is equal $sql_compare = '='; $sql_value = "'{$value}'"; break; case 42: // number is not equal $sql_compare = '!='; $sql_value = "'{$value}'"; break; case 43: // number is greater than $sql_compare = '>'; $sql_value = "'{$value}'"; break; case 44: // number is less than $sql_compare = '<'; $sql_value = "'{$value}'"; break; case 60: // string do not compare // explicitly skip adding a clause when $compare == 60 ( "--" in the GUI ) break; case 61: // string is equal $sql_compare = '='; $sql_value = "'{$value}'"; break; case 62: // string is not equal $sql_compare = '!='; $sql_value = "'{$value}'"; break; case 63: // string contains $sql_compare = 'LIKE'; $sql_value = "'%{$value}%'"; break; case 64: // string does not contain $sql_compare = 'NOT LIKE'; $sql_value = "'%{$value}%'"; break; case 65: // string starts with $sql_compare = 'LIKE'; $sql_value = "'{$value}%'"; break; case 66: // string ends with $sql_compare = 'LIKE'; $sql_value = "'%{$value}'"; break; case 80: // date do not compare // explicitly skip adding a clause when $compare == 80 ( "--" in the GUI ) break; case 81: // date is equal $sql_compare = '='; $sql_value = get_sql_date_value($value); break; case 82: // date is not equal $sql_compare = '!='; $sql_value = get_sql_date_value($value); break; case 83: // date is after $sql_compare = '>'; $sql_value = get_sql_date_value($value); break; case 84: // date is before $sql_compare = '<'; $sql_value = get_sql_date_value($value); break; default: trigger_error('unknown $compare value: ' . $compare, E_USER_WARNING); break; } return array($sql_compare, $sql_value); }
function get_sql_compare_and_value($compare, $value) { $sql_compare = ''; $sql_value = ''; switch ($compare) { case 0: // bool do not compare // explicitly skip adding a clause when $compare == 0 ( "--" in the GUI ) break; case 1: // bool is true $sql_compare = '!='; $sql_value = '0'; break; case 2: // bool is false $sql_compare = '='; $sql_value = '0'; break; case 40: // number do not compare // explicitly skip adding a clause when $compare == 40 ( "--" in the GUI ) break; case 41: // number is equal $sql_compare = '='; $sql_value = "'{$value}'"; break; case 42: // number is not equal $sql_compare = '!='; $sql_value = "'{$value}'"; break; case 43: // number is greater than $sql_compare = '>'; $sql_value = "'{$value}'"; break; case 44: // number is less than $sql_compare = '<'; $sql_value = "'{$value}'"; break; case 60: // string do not compare // explicitly skip adding a clause when $compare == 60 ( "--" in the GUI ) break; case 61: // string is equal $sql_compare = '='; $sql_value = "'{$value}'"; break; case 62: // string is not equal $sql_compare = '!='; $sql_value = "'{$value}'"; break; case 63: // string contains $sql_compare = 'LIKE'; $sql_value = "'%{$value}%'"; break; case 64: // string does not contain $sql_compare = 'NOT LIKE'; $sql_value = "'%{$value}%'"; break; case 65: // string starts with $sql_compare = 'LIKE'; $sql_value = "'{$value}%'"; break; case 66: // string ends with $sql_compare = 'LIKE'; $sql_value = "'%{$value}'"; break; case 80: // date do not compare // explicitly skip adding a clause when $compare == 80 ( "--" in the GUI ) break; case 81: // date is equal $sql_compare = '='; $sql_value = get_sql_date_value($value); break; case 82: // date is not equal $sql_compare = '!='; $sql_value = get_sql_date_value($value); break; case 83: // date is after $sql_compare = '>'; $sql_value = get_sql_date_value($value); break; case 84: // date is before $sql_compare = '<'; $sql_value = get_sql_date_value($value); break; case 92: case 93: // Include or exclude a SubProject from the parent summary. // This has to be handled via custom logic, // not just by tweaking the SQL query. $sql_compare = ''; $sql_value = ''; break; default: trigger_error('unknown $compare value: ' . $compare, E_USER_WARNING); break; } return array($sql_compare, $sql_value); }