Skip to content

Instantly share code, notes, and snippets.

@jlamim
Created April 16, 2016 00:04
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 jlamim/d3666fa399d791795780d8c148fff682 to your computer and use it in GitHub Desktop.
Save jlamim/d3666fa399d791795780d8c148fff682 to your computer and use it in GitHub Desktop.
Contatos_model - Criando um CRUD com CodeIgniter
<?php
class Contatos_model extends MY_Model {
function __construct() {
parent::__construct();
$this->table = 'contatos';
}
/**
* Formata os contatos para exibição dos dados na home
*
* @param array $contatos Lista dos contatos a serem formatados
*
* @return array
*/
function Formatar($contatos){
if($contatos){
for($i = 0; $i < count($contatos); $i++){
$contatos[$i]['editar_url'] = base_url('editar')."/".$contatos[$i]['id'];
$contatos[$i]['excluir_url'] = base_url('excluir')."/".$contatos[$i]['id'];
}
return $contatos;
} else {
return false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment