Pimcore\Model\User\AbstractUser\Dao::getById PHP Method

getById() public method

public getById ( $id )
$id
    public function getById($id)
    {
        if ($this->model->getType()) {
            $data = $this->db->fetchRow("SELECT * FROM users WHERE `type` = ? AND id = ?", [$this->model->getType(), $id]);
        } else {
            $data = $this->db->fetchRow("SELECT * FROM users WHERE `id` = ?", $id);
        }
        if (is_numeric($data["id"])) {
            $this->assignVariablesToModel($data);
        } else {
            throw new \Exception("user doesn't exist");
        }
    }

Usage Example

Beispiel #1
0
 /**
  * @param $id
  * @throws \Exception
  */
 public function getById($id)
 {
     parent::getById($id);
     if (in_array($this->model->getType(), ["user", "role"])) {
         $this->loadWorkspaces();
     }
 }