Skip to content

Instantly share code, notes, and snippets.

@luisdalmolin
Created September 25, 2012 01:34
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 luisdalmolin/3779476 to your computer and use it in GitHub Desktop.
Save luisdalmolin/3779476 to your computer and use it in GitHub Desktop.
EscapeWork: Base Class
<?php
/**
* Description
*
* @author Seu nome <email@escape.ppg.br>
*/
class NomeDaClasse extends EscapeWork
{
/**
* Variaveis da tabela
*
* @access protected
*/
protected
$id;
/**
* Construtor da classe
*
* @access public
* @return void
*/
public function __construct()
{
parent::__construct( TAB . '_nome_da_tabela' );
}
/**
* Inserindo uma nova noticia
*
* @access public
* @return boolean
*/
public function insert( $debug = false )
{
# inserindo
if( parent::insert( $debug ) )
{
Msg::setMsg('O registro <strong>'.$this->_get('titulo').'</strong> foi inserido com sucesso');
return true;
}
else
{
Msg::setErro('Houve um erro ao inserir o registro, por favor tente novamente');
return false;
}
}
/**
* Editando uma noticia
*
* @access public
* @return boolean
*/
public function update( $debug = false )
{
if( parent::update( $debug ) )
{
Msg::setMsg('O registro <strong>'.$this->_get('titulo').'</strong> foi editado com sucesso');
return true;
}
else
{
Msg::setErro('Houve um erro ao editar o registro, por favor, tente novamente');
return false;
}
}
/**
* Excluindo um registro
*
* @access public
* @return boolean
*/
public function delete( $debug = false )
{
# verificando se existe
if( !$this->informacoes() )
{
Msg::setErro('O registro selecionada não existe');
return false;
}
# excluindo o registro
if( parent::delete() )
{
Msg::setMsg('O registro <strong>'.$this->_get('titulo').'</strong> foi excluído com sucesso.');
return true;
}
else
{
Msg::setErro('Houve um erro ao excluir o registro. Por favor, tente novamente.');
return false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment