_db->select(); $select->from($this->_getPair(), ['id']); $select->join($this->_getPair('Company'), '`User`.`companyId` = `Company`.`id`', []); $select->where('`User`.`email` = ?', $email); $select->where('`User`.`status` = ?', UserEntity::STATUS_ACTIVE); $select->where('`Company`.`status` = ?', CompanyEntity::STATUS_ACTIVE); if (false !== ($id = $this->_db->fetchOne($select))) { $this->setPrimaryKey($id); } return $this; } /** * Set primary key for recover code * * @param string $recoverCode * @return Obj */ public function setPrimaryKeyByRecoverCode($recoverCode) { $select = $this->_db->select(); $select->from($this->_getPair(), ['id']); $select->join($this->_getPair('Company'), '`User`.`companyId` = `Company`.`id`', []); $select->where('`User`.`recoverCode` = ?', $recoverCode); $select->where('`User`.`status` = ?', UserEntity::STATUS_ACTIVE); $select->where('`Company`.`status` = ?', CompanyEntity::STATUS_ACTIVE); if (false !== ($id = $this->_db->fetchOne($select))) { $this->setPrimaryKey($id); } return $this; } /** * Set code for password recover * * @param string $recoverCode * @param string $expirationDate * @return Obj */ public function setRecoverCode($recoverCode, $expirationDate) { $updateData = array( 'recoverCode' => $recoverCode, 'recoverCodeExpirationDate' => $expirationDate ); $this->_getTable()->updateByKey($updateData, $this->_primaryKey); return $this; } protected function _insertDependency() { return $this; } protected function _updateDependency() { return $this; } protected function _deleteDependency() { return $this; } }