Last active
April 28, 2016 04:34
-
-
Save jlamim/fa8d606565f795bd050ba4162e657df5 to your computer and use it in GitHub Desktop.
Importando dados CSV com CodeIgniter - Model
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
<?php | |
class Csv_model extends CI_Model { | |
/** | |
* Método construtor | |
* | |
* @access public | |
* @return void | |
*/ | |
function __construct() { | |
parent::__construct(); | |
} | |
/** | |
* Recupera todos os contatos da tabela 'contatos' | |
* | |
* @access public | |
* @return void | |
*/ | |
function get_contatos() { | |
$query = $this->db->get('contatos'); | |
if ($query->num_rows() > 0) { | |
return $query->result_array(); | |
} else { | |
return FALSE; | |
} | |
} | |
/** | |
* Insere o contato na tabela 'contatos' | |
* | |
* @access public | |
* @return void | |
*/ | |
function insert_csv($data) { | |
$this->db->insert('contatos', $data); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment