Skip to content

Instantly share code, notes, and snippets.

@valdiney
Created March 19, 2016 05:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save valdiney/57460cf21f667e28ab22 to your computer and use it in GitHub Desktop.
Save valdiney/57460cf21f667e28ab22 to your computer and use it in GitHub Desktop.
<?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