Created
July 11, 2012 12:58
-
-
Save hugoleodev/3090248 to your computer and use it in GitHub Desktop.
Mapeamento de tabela "usuario" pelo Doctrine 2
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 | |
/* | |
* Workshop Doctrine 2 + ZF1 | |
* | |
*/ | |
namespace Application\Entity; | |
/** | |
* Usuario | |
* @author Administrator | |
*/ | |
class Usuario | |
{ | |
protected $id; | |
/** | |
* @var string nome do usuário | |
*/ | |
protected $nome; | |
/** | |
* @var string login do usuário | |
*/ | |
protected $login; | |
/** | |
* @var string senha criptografada | |
*/ | |
protected $senha; | |
/** | |
* Retorna o ID do usuário | |
* @return integer | |
*/ | |
public function getId() | |
{ | |
return $this->id; | |
} | |
/** | |
* Retorna o nome do usuário | |
* @return string | |
*/ | |
public function getNome() | |
{ | |
return $this->nome; | |
} | |
/** | |
* Seta o nome do usuário | |
* @param string $nome | |
*/ | |
public function setNome($nome) | |
{ | |
$this->nome = $nome; | |
} | |
/** | |
* Retorna o login do usuário | |
* @return string | |
*/ | |
public function getLogin() | |
{ | |
return $this->login; | |
} | |
/** | |
* Seta o login do usuário | |
* @param string $login | |
*/ | |
public function setLogin($login) | |
{ | |
$this->login = $login; | |
} | |
/** | |
* Retorna a senha do usuário | |
* @return string | |
*/ | |
public function getSenha() | |
{ | |
return $this->senha; | |
} | |
/** | |
* Seta e Criptografa a senha do usuário | |
* @param string $senha | |
*/ | |
public function setSenha($senha) | |
{ | |
$this->senha = $this->criptografaSenha($senha); | |
} | |
/** | |
* Criptografa a senha do usuário | |
* @param string $senha valor a ser criptografado | |
* @return string | |
*/ | |
private function criptografaSenha($senha) | |
{ | |
return md5($senha); | |
} | |
} |
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 | |
/* | |
* Workshop Doctrine 2 + ZF1 | |
* | |
*/ | |
namespace Application\Entity; | |
/** | |
* Usuario | |
* @Entity | |
* @Table(name="usuario") | |
* @author Administrator | |
* @category Somente para mostrar que os annotations não influenciam no | |
* Doctrine 2 | |
*/ | |
class Usuario | |
{ | |
/** | |
* @Id | |
* @GeneratedValue(strategy="AUTO") | |
* @Column(type="integer") | |
* @var integer ID do usuário | |
*/ | |
protected $id; | |
/** | |
* @Column(type="string", nullable="false") | |
* @var string nome do usuário | |
*/ | |
protected $nome; | |
/** | |
* @Column(type="string", nullable="false") | |
* @var string login do usuário | |
*/ | |
protected $login; | |
/** | |
* @Column(type="string") | |
* @var string senha criptografada | |
*/ | |
protected $senha; | |
/** | |
* Retorna o ID do usuário | |
* @return integer | |
*/ | |
public function getId() | |
{ | |
return $this->id; | |
} | |
/** | |
* Retorna o nome do usuário | |
* @return string | |
*/ | |
public function getNome() | |
{ | |
return $this->nome; | |
} | |
/** | |
* Seta o nome do usuário | |
* @param string $nome | |
*/ | |
public function setNome($nome) | |
{ | |
$this->nome = $nome; | |
} | |
/** | |
* Retorna o login do usuário | |
* @return string | |
*/ | |
public function getLogin() | |
{ | |
return $this->login; | |
} | |
/** | |
* Seta o login do usuário | |
* @param string $login | |
*/ | |
public function setLogin($login) | |
{ | |
$this->login = $login; | |
} | |
/** | |
* Retorna a senha do usuário | |
* @return string | |
*/ | |
public function getSenha() | |
{ | |
return $this->senha; | |
} | |
/** | |
* Seta e Criptografa a senha do usuário | |
* @param string $senha | |
*/ | |
public function setSenha($senha) | |
{ | |
$this->senha = $this->criptografaSenha($senha); | |
} | |
/** | |
* Criptografa a senha do usuário | |
* @param string $senha valor a ser criptografado | |
* @return string | |
*/ | |
private function criptografaSenha($senha) | |
{ | |
return md5($senha); | |
} | |
} |
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
<?xml version="1.0" encoding="utf-8"?> | |
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> | |
<entity name="Application\Entity\Usuario" table="usuario"> | |
<change-tracking-policy>DEFERRED_IMPLICIT</change-tracking-policy> | |
<id name="id" type="integer" column="id"> | |
<generator strategy="IDENTITY"/> | |
</id> | |
<field name="nome" type="string" column="nome" precision="0" scale="0"/> | |
<field name="login" type="string" column="login" precision="0" scale="0"/> | |
<field name="senha" type="string" column="senha" precision="0" scale="0"/> | |
<lifecycle-callbacks/> | |
</entity> | |
</doctrine-mapping> |
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
Application\Entity\Usuario: | |
type: entity | |
table: usuario | |
fields: | |
id: | |
type: integer | |
length: null | |
precision: 0 | |
scale: 0 | |
nullable: false | |
unique: false | |
id: true | |
generator: | |
strategy: IDENTITY | |
nome: | |
type: string | |
length: null | |
precision: 0 | |
scale: 0 | |
nullable: 'false' | |
unique: false | |
login: | |
type: string | |
length: null | |
precision: 0 | |
scale: 0 | |
nullable: 'false' | |
unique: false | |
senha: | |
type: string | |
length: null | |
precision: 0 | |
scale: 0 | |
nullable: false | |
unique: false | |
lifecycleCallbacks: { } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment