/** * verifica_se_pode * Verifica se eleitor ja votou na eleição corrente * * @author joao paulo bastos <jpbl.bastos at gmail dot com> * @param int $ideleitor * @return boolean */ private function verifica_se_pode($ideleitor) { /* inicializa sql */ $this->sql = ''; $this->sql = "SELECT votacao.ideleitor_eleitor FROM eleicao.votacao WHERE votacao.ideleitor_eleitor = " . $ideleitor . " AND votacao.idparametro_parametro = " . $this->idparametro . " ; "; if (!$this->db->query($this->sql)) { $this->erro_msg = $this->db->erroMsg; return false; } if ($this->db->num_rows() > 0) { // ja vottou return true; } else { // não votou return false; } }
/** * verifica_eleitor * Faz a verificação se existe um eleitor, se existe já preenche seus atributos * * @author joao paulo bastos <jpbl.bastos at gmail dot com> * @param string $email [email a ser consultado] * @return boolean [true se existe / false se não exite ou e caso de falhas] */ public function verifica_eleitor($email = '') { /* inicializa sql */ $this->sql = ''; $flag = null; /* Verifica se foi passado o parametro */ if (empty($email)) { $this->erro_msg = "OPS, erro o parametro e-mail não foi informado. Impossivel fazer a consulta ! :("; return false; } /* prepara sql */ $this->sql = "SELECT ideleitor FROM eleicao.eleitor WHERE eleitor.email = '" . $email . "';"; /* Trabalhando com a base de dados */ if (!$this->db->open()) { $this->erro_msg = $this->db->erroMsg; return false; } if (!$this->db->query($this->sql)) { $this->erro_msg = $this->db->erroMsg; return false; } $flag = $this->db->num_rows(); if ($flag === 1) { $flag = null; $flag = $this->db->fetch(); $this->set_dado('ideleitor', $flag['ideleitor']); $this->db->close(); /* Busca os dados */ if ($this->consulta_eleitor()) { return true; } else { return false; } } else { $this->erro_msg = "OPS, o e-mail " . $email . ", não exite na base de dados ! :("; $this->erro_cod = 100; // eleitor não existe $this->db->close(); return false; } /* Finalizando com o banco */ }