Skip to content

Commit

Permalink
Added null values for columns that don't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Dean Sofer committed Jan 14, 2011
1 parent c24e945 commit 54cb826
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions models/behaviors/csv.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ function importCsv(&$model, $content, $fields = array(), $options = array()) {
while ($row = fgetcsv($file, $options['length'], $options['delimiter'], $options['enclosure'])) { while ($row = fgetcsv($file, $options['length'], $options['delimiter'], $options['enclosure'])) {
// for each header field // for each header field
foreach ($fields as $f => $field) { foreach ($fields as $f => $field) {
if (!isset($row[$f])) {
$row[$f] = null;
}
// get the data field from Model.field // get the data field from Model.field
if (strpos($field,'.')) { if (strpos($field,'.')) {
$keys = explode('.',$field); $keys = explode('.',$field);
Expand Down

0 comments on commit 54cb826

Please sign in to comment.