Last active
December 17, 2015 02:19
-
-
Save atishgoswami/5534672 to your computer and use it in GitHub Desktop.
SQL Conditional Field Query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$conditionalField | |
= '(IF( User.joined_date IS NOT NULL, | |
DATE_FORMAT(User.joined_date, "%d-%m"), | |
DATE_FORMAT(User.created, "%d-%m")))'; | |
$conditionalField2 | |
= '(IF( User.joined_date IS NOT NULL, | |
DATE_FORMAT(User.joined_date, "%Y"), | |
DATE_FORMAT(User.created, "%Y")))'; | |
$this->User->recursive = -1; | |
$flag = true; | |
$options['conditions'] = array( | |
$conditionalField => $presentDate, | |
$conditionalField2.' <'=> date('Y'), | |
'User.company_id' => AuthComponent::user('company_id'), | |
'User.account_status' => $userInstance::ACTIVE, | |
); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment