views:

21

answers:

1

Hi,

Anyone know why this method is call EVERY TIME "$this->vagas_model->new_jobcv_entry($db_array);" even when the if was false...

tkz in advice


if($this->tank_auth->is_logged_in()){
if(!$this->tank_auth->is_company()){

    $db_array = array(
    'jobs_id' => $jobs_id,
    'user_id' => $this->session->userdata('user_id'),
    'created_by' => 'Hora do emprego'
    );

    print_r($db_array);
    if($this->vagas_model->is_user_in_this_job($db_array['user_id'],$db_array['jobs_id']) == true)
    {
        echo "entrou";
        $data['body'] = 'CV já enviado para esta vaga.';
    }else{
        echo "droga";
        $this->vagas_model->new_jobcv_entry($db_array);

        $data['body'] = 'enviado';
    }

    }else{
        $data['body'] = "Apenas para empresas";
    }

    }else{
        $data['body'] = "Precisa estar logado";
}

echo modules::run('index/iframe',$data);
A: 
if ($this->vagas_model->is_user_in_this_job(...) == true) {
    ...
} else {
    // if the condition was false, this code will get executed:
    ...
    $this->vagas_model->new_jobcv_entry($db_array);
    ...
}

I'm not surprised it gets executed when the condition is false.
Do you have an example that shows something more unusual?

deceze
if ($this->vagas_model->is_user_in_this_job($db_array['user_id'], $db_array['jobs_id']) == true) { echo "TRUE";} else { $this->vagas_model->new_jobcv_entry($db_array); echo "FALSE";}My output is TRUE but the method below is called anyway
Roberto
@Roberto Then it seems like it's called from somewhere else as well. Try a `debug_backtrace` inside `new_jobcv_entry()`.
deceze