I'm trying to insert into DB when and it is in the following condition:
public function cadastrar_agendamento($dados){
$consulta = $this->db->query('
SELECT cod_lab, cod_data, cod_horario, cod_assento, al_reg, dataagendamento
FROM P_chekin_Geral
WHERE (al_reg = "'.NULL.'") AND (cod_lab = "'.$dados['laboratorio'].'") AND (cod_data = "'.$dados['data_prova'].'") AND (cod_data = "'.$dados['horario_prova'].'")
');
if ($consuta){
$query = mssql_query('INSERT INTO P_chekin_Geral (al_reg, dataagendamento) VALUES ("'.$dados->matricula.'"’, "'.$dados->dataagendamento.'")') ;
}
}
But it does not insert, since the bank is already filled with NULL in the fields al_reg, datedate and the other fields are already filled in.