This is kind of a stupid question but I'm in doubt:
I'm checking below that a function (which queries my db) doesn't return NULL and redirecting if it does.
If it doesn't I then assign it to an array.
In the code below, is the query ran twice?
if (!$this->review_model->GetReview($data['review_type'], $data['review_id'])) {
redirect();
}
$data['review'] = $this->review_model->GetReview($data['review_type'], $data['review_id']);
Yes, it runs twice if not redirected...
Do this
$data['review'] = $this->review_model->GetReview($data['review_type'], $data['review_id']);
if (!$data['review']) {
redirect();
}
For your question, No, once redirect()
method called, further line not executed.
But your checking is not good. you can change it is as following
$data['review'] = $this->review_model->GetReview($data['review_type'], $data['review_id']);
if(!$data['review']){
redirect();
}