PageRenderTime 21ms CodeModel.GetById 13ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/dao/LoginDao.php

https://bitbucket.org/denissilva/cgpdi_admin
PHP | 28 lines | 26 code | 2 blank | 0 comment | 1 complexity | bc2105c2f4eea01acaeb1416def1ad54 MD5 | raw file
 1<?php
 2    require_once ('../../classes/Login.php');
 3    require_once ('../../classes/Database.php');
 4
 5    class LoginDao {
 6        private $conexao;
 7        public function __construct(){
 8            $db = new Database();
 9            $this->conexao = $db->getConection();
10        }
11
12        public function logar(Login $login) {
13            try {
14                $sql = "SELECT * FROM usuarios_novo WHERE email = '{$login->getEmail()}' AND senha = '{$login->getSenha()}'";
15                $result = $this->conexao->query($sql);
16                $rows = array();
17                if($result->num_rows > 0) {
18                    while($row = $result->fetch_assoc()) {
19                        $rows[] = $row;
20                    }
21                }
22                return json_encode($rows);
23            } catch (Exception $ex) {
24                echo $ex->getMessage();
25            }
26        }
27    }
28?>