0
I’m using the oracle bank. When I sign up for an Employee, the page displays success when registering. But when I check the bank, it doesn’t appear there. Did my code have some logic error that I didn’t realize. Follow the code of the DAO module.
<?php
class CrudDAO {
    public function buscarPorId($id){
        $sql = "
select *
from pfj.employees
where id = ?
        ";
        return query($sql, [$id], QUERY_PRIMEIRO);
    }
    public function existePorEmail($empId, $emailExistente){
        $listaWhere = [];
        $parametros = [];
        $listaWhere[] = 'employee_id = :empid';
        $parametros['empid'] = $empId;
        if (isset($emailExistente)) {
            $listaWhere[] = 'email <> :email';
            $parametros['email'] = $emailExistente;
        }
        $sqlWhere = implode(' and ', $listaWhere);
        $sql = "
select count(*)
from pfj.employees
where $sqlWhere
        ";
        return (bool)query($sql, $parametros, QUERY_PRIMEIRO_VALOR);
    }
    public function salvar($registro) {
//        $registro = array_filter_keys($registro, [`empid`, `nome`, `sobrenome`, `email`, `celular`, `hiredate`, `jobid`, `salary`]);
//        if (isset($registro['empid'])) {
//
//            $sql = "update pfj.employees
//                    set employee_id  = :empid,
//                       first_name   = :nome,
//                       last_name    = :sobrenome,
//                       email        = :email,
//                       phone_number = :celular,
//                       hire_date    = :hiredate,
//                       job_id       = :jobid,
//                       salary       = :salary
//                    where employee_id = :empid";
//
//            query($sql, $registro);
//            
//        }else {
            $registro = array_filter_keys($registro, [`empid`, `nome`, `sobrenome`, `email`, `celular`, `hiredate`, `jobid`, `salary`]);
            if (isset($registro['empid'])) {
            $sql = "insert into pfj.employees
                  (employee_id,
                   first_name,
                   last_name,
                   email,
                   phone_number,
                   hire_date,
                   job_id,
                   salary)
                   values
                    (:empid, :nome, :sobrenome, :email, :celular, :hiredate, :jobid, :salary)
                ";
            query($sql, $registro);
        }
    }
    }
But if I use an id of a registered Employee, it displays the error message. That part is at least ok.