Last active
December 16, 2015 10:32
-
-
Save mstaack/48f59ea3d7ed0f916b2b to your computer and use it in GitHub Desktop.
Create Criteria From fields and values
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
private function getCriteriaForRow($row) | |
{ | |
$fullCriteria = new CDbCriteria(); | |
foreach ($this->mapping as $uploadColumn => $databaseColumn) { | |
$value = $row[array_search($uploadColumn, $this->fileHeader)]; | |
$criteria = new CDbCriteria(); | |
$criteria->condition = $databaseColumn . '=:' . $databaseColumn; | |
$criteria->params = [':' . $databaseColumn => $value]; | |
$fullCriteria->mergeWith($criteria, $operator = 'AND'); | |
} | |
return $fullCriteria; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment