Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Entities;
- use Entities\Repositories,
- Entities\Repositories\AdminUserRepository;
- /**
- * AdminUser
- *
- * @Table(name="admin_user")
- * @Entity(repositoryClass="Entities\Repositories\AdminUserRepository")
- */
- class AdminUser
- {
- const ACCOUNT_STATUS_ACTIVE = 1;
- const ACCOUNT_STATUS_PENDING = 2;
- const ACCOUNT_STATUS_DISABLED = 3;
- protected $accountStatusNames = array(
- self::ACCOUNT_STATUS_ACTIVE => 'active',
- self::ACCOUNT_STATUS_PENDING => 'pending',
- self::ACCOUNT_STATUS_DISABLED => 'disabled'
- );
- /**
- * @var integer $id
- *
- * @Column(name="id", type="integer", length=4)
- * @Id
- * @GeneratedValue(strategy="IDENTITY")
- */
- private $id;
- /**
- * @var integer $role_id
- *
- * @Column(name="role_id", type="integer", length=4)
- * @OneToOne(targetEntity="Role")
- */
- private $role_id;
- /**
- * @var string $email_address
- *
- * @Column(name="email_address", type="string", length=255)
- */
- private $email_address;
- /**
- * @var string $password
- *
- * @Column(name="password", type="string", length=50)
- */
- private $password;
- /**
- * @var string $title
- *
- * @Column(name="title", type="string", length=4, nullable=true)
- */
- private $title;
- /**
- * @var string $first_name
- *
- * @Column(name="first_name", type="string", length=50)
- */
- private $first_name;
- /**
- * @var string $last_name
- *
- * @Column(name="last_name", type="string", length=50)
- */
- private $last_name;
- /**
- * @var string $company_name
- *
- * @Column(name="company_name", type="string", length=255, nullable=true)
- */
- private $company_name;
- /**
- * @var string $telephone_number
- *
- * @Column(name="telephone_number", type="string", length=20, nullable=true)
- */
- private $telephone_number;
- /**
- * @var string $account_status
- *
- * @Column(name="account_status", type="integer", length=4)
- */
- private $account_status;
- /**
- * @var datetime $date_created
- *
- * @Column(name="date_created", type="datetime", nullable=true)
- */
- private $date_created;
- /**
- * @var datetime $last_updated
- *
- * @Column(name="last_updated", type="datetime", nullable=true)
- */
- private $last_updated;
- /**
- * Get id
- *
- * @return integer $id
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set role_id
- *
- * @param string $roleId
- */
- public function setRoleId($roleId)
- {
- $this->role_id = $roleId;
- }
- /**
- * Get role_id
- *
- * @return string $roleId
- */
- public function getRoleId()
- {
- return $this->role_id;
- }
- /**
- * Set email_address
- *
- * @param string $emailAddress
- */
- public function setEmailAddress($emailAddress)
- {
- $this->email_address = $emailAddress;
- }
- /**
- * Get email_address
- *
- * @return string $emailAddress
- */
- public function getEmailAddress()
- {
- return $this->email_address;
- }
- /**
- * Set password
- *
- * @param string $password
- */
- public function setPassword($password)
- {
- $this->password = md5($password . AdminUserRepository::getSecretCode());
- }
- /**
- * Get password
- *
- * @return string $password
- */
- public function getPassword()
- {
- return $this->password;
- }
- /**
- * Set title
- *
- * @param string $title
- */
- public function setTitle($title)
- {
- $this->title = $title;
- }
- /**
- * Get title
- *
- * @return string $title
- */
- public function getTitle()
- {
- return $this->title;
- }
- /**
- * Set first_name
- *
- * @param string $firstName
- */
- public function setFirstName($firstName)
- {
- $this->first_name = $firstName;
- }
- /**
- * Get first_name
- *
- * @return string $firstName
- */
- public function getFirstName()
- {
- return $this->first_name;
- }
- /**
- * Set last_name
- *
- * @param string $lastName
- */
- public function setLastName($lastName)
- {
- $this->last_name = $lastName;
- }
- /**
- * Get last_name
- *
- * @return string $lastName
- */
- public function getLastName()
- {
- return $this->last_name;
- }
- /**
- * Set company_name
- *
- * @param string $companyName
- */
- public function setCompanyName($companyName)
- {
- $this->company_name = $companyName;
- }
- /**
- * Get company_name
- *
- * @return string $companyName
- */
- public function getCompanyName()
- {
- return $this->company_name;
- }
- /**
- * Set telephone_number
- *
- * @param string $telephoneNumber
- */
- public function setTelephoneNumber($telephoneNumber)
- {
- $this->telephone_number = $telephoneNumber;
- }
- /**
- * Get telephone_number
- *
- * @return string $telephoneNumber
- */
- public function getTelephoneNumber()
- {
- return $this->telephone_number;
- }
- /**
- * Set account_status
- *
- * @param string $accountStatus
- */
- public function setAccountStatus($accountStatus)
- {
- $this->account_status = $accountStatus;
- }
- /**
- * Get account_status
- *
- * @return string $accountStatus
- */
- public function getAccountStatus()
- {
- return $this->account_status;
- }
- /**
- * Set date_created
- *
- * @param datetime $dateCreated
- */
- public function setDateCreated($dateCreated)
- {
- $this->date_created = $dateCreated;
- }
- /**
- * Get date_created
- *
- * @return datetime $dateCreated
- */
- public function getDateCreated()
- {
- return $this->date_created;
- }
- /**
- * Set last_updated
- *
- * @param datetime $lastUpdated
- */
- public function setLastUpdated($lastUpdated)
- {
- $this->last_updated = $lastUpdated;
- }
- /**
- * Get last_updated
- *
- * @return datetime $lastUpdated
- */
- public function getLastUpdated()
- {
- return $this->last_updated;
- }
- }
- <?php
- namespace Entities;
- /**
- * Role
- *
- * @Table(name="role")
- * @Entity(repositoryClass="Entities\Repositories\RoleRepository")
- */
- class Role
- {
- const STATUS_ACTIVE = 1;
- const STATUS_DISABLED = 2;
- protected $statusNames = array(
- self::STATUS_ACTIVE => 'active',
- self::STATUS_DISABLED => 'disabled'
- );
- /**
- * @var integer $id
- *
- * @Column(name="id", type="integer", length=4)
- * @Id
- * @GeneratedValue(strategy="IDENTITY")
- */
- private $id;
- /**
- * @var string $name
- *
- * @Column(name="name", type="string", length=255)
- */
- private $name;
- /**
- * @var integer $parent_id
- *
- * @Column(name="parent_id", type="integer", length=4, nullable=true)
- */
- private $parent_id;
- /**
- * @var string $status
- * @Column(name="status", type="integer", length=4)
- */
- private $status;
- public function __construct()
- {
- // Set default values
- $this->setStatus(1);
- }
- /**
- * Get id
- *
- * @return integer $id
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set name
- *
- * @param string $name
- */
- public function setName($name)
- {
- $this->name = $name;
- }
- /**
- * Get name
- *
- * @return string $name
- */
- public function getName()
- {
- return $this->name;
- }
- /**
- * Set parent_id
- *
- * @param integer $parentId
- */
- public function setParentId($parentId)
- {
- $this->parent_id = $parentId;
- }
- /**
- * Get parent_id
- *
- * @return integer $parentId
- */
- public function getParentId()
- {
- return $this->parent_id;
- }
- /**
- * Set status
- *
- * @param integer $status
- */
- public function setStatus($status)
- {
- $this->status = $status;
- }
- /**
- * Get status
- *
- * @return integer $status
- */
- public function getStatus()
- {
- return $this->status;
- }
- }
- $qb = $this->em->createQueryBuilder()
- ->select('a, r')
- ->from('Entities\AdminUser', 'a')
- ->leftJoin('a.role_id', 'r');
- $query = $qb->getQuery();
- $user = $query->getResult(Doctrine\ORM\Query::HYDRATE_ARRAY);
- var_dump($user);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement