Created
September 25, 2012 01:34
-
-
Save luisdalmolin/3779476 to your computer and use it in GitHub Desktop.
EscapeWork: Base Class
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 | |
/** | |
* 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