Created
March 19, 2016 05:07
-
-
Save valdiney/57460cf21f667e28ab22 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
# Using this class you will record the excel archive to the table in your database | |
class RecordExcelLine | |
{ | |
private $archive; | |
private $model; | |
public function __construct(Usuario $model) | |
{ | |
$this->model = $model; | |
} | |
public function setArchive($archive) | |
{ | |
$this->archive = fopen($archive, 'r'); | |
} | |
public function record() | |
{ | |
while (! feof($this->archive)) { | |
$line = fgets($this->archive, 1024); | |
$data = explode(';', $line); | |
if (! empty($line)) { | |
$this->model->cadastraUsuarioExcel($data[0], $data[1], $data[2]); | |
} | |
} | |
fclose($this->archive); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment