| @@ -9,8 +9,9 @@ | ||
| 9 | 9 | { |
| 10 | 10 | |
| 11 | 11 | protected $enclosure = '"'; |
| 12 | 12 | protected $delimiter = ','; |
| 13 | + protected $escape = '\\'; | |
| 13 | 14 | |
| 14 | 15 | |
| 15 | 16 | /** |
| 16 | 17 | * Set Enclosure |
| @@ -31,8 +32,13 @@ | ||
| 31 | 32 | { |
| 32 | 33 | $this->delimiter = $delimiter; |
| 33 | 34 | } |
| 34 | 35 | |
| 36 | + public function setEscape($escape) | |
| 37 | + { | |
| 38 | + $this->escape = $escape; | |
| 39 | + } | |
| 40 | + | |
| 35 | 41 | /** |
| 36 | 42 | * Get Delimiter |
| 37 | 43 | * |
| 38 | 44 | * @return string |
| @@ -51,8 +57,13 @@ | ||
| 51 | 57 | { |
| 52 | 58 | return $this->enclosure; |
| 53 | 59 | } |
| 54 | 60 | |
| 61 | + public function getEscape() | |
| 62 | + { | |
| 63 | + return $this->enclosure === $this->escape ? '' : $this->escape; | |
| 64 | + } | |
| 65 | + | |
| 55 | 66 | /** |
| 56 | 67 | * Generate record file positions |
| 57 | 68 | * |
| 58 | 69 | * Loop through each record and save each position |
| @@ -68,9 +79,9 @@ | ||
| 68 | 79 | rewind($this->getFileHandle()); |
| 69 | 80 | while (!feof($this->getFileHandle())) { |
| 70 | 81 | |
| 71 | 82 | $startIndex = ftell($this->getFileHandle()); |
| 72 | - $row = fgetcsv($this->getFileHandle(), 0, $this->getDelimiter(), $this->getEnclosure()); | |
| 83 | + $row = fgetcsv($this->getFileHandle(), 0, $this->getDelimiter(), $this->getEnclosure(), $this->getEscape()); | |
| 73 | 84 | |
| 74 | 85 | if (!empty($row)) { |
| 75 | 86 | $this->setIndex($record, $startIndex, ftell($this->getFileHandle())); |
| 76 | 87 | $record++; |
| @@ -75,9 +86,9 @@ | ||
| 75 | 86 | $this->setIndex($record, $startIndex, ftell($this->getFileHandle())); |
| 76 | 87 | $record++; |
| 77 | 88 | } |
| 78 | 89 | |
| 79 | - if ($this->is_processing && ($record >= 2 || $startIndex > $this->process_max_size)) { | |
| 90 | + if ($this->is_processing && $startIndex > $this->process_max_size) { | |
| 80 | 91 | break; |
| 81 | 92 | } |
| 82 | 93 | |
| 83 | 94 | $current_pos = intval(ftell($this->getFileHandle())); |