I need to pass a condition to a wherestring instead of a string identifier due to reasons. The problem is that the condition somehow captures only the first word of the selected value. For example, look at this piece of code:
<select id="brand" name="brand" required>
<option value="Lorem Ipsum Dolor" selected>Lorem Ipsum Dolor</option>
</select>
Then, repeating last_query(), the condition will show:
... WHERE `table.column` = `Lorem` ...
Instead of everything value.
This is my request:
public function find_id_ano_modelo($marca, $modelo, $ano, $comb)
{
$this->db
->select('ano_modelo.id')
->join('modelo', 'modelo.id = ano_modelo.id_modelo')
->join('marca', 'marca.id_marca = modelo.id_marca')
->where('marca.id_marca', $marca)
->where('modelo.modelo', $modelo)
->where('ano_modelo.ano', $ano)
->where('ano_modelo.combustivel', $comb)
->where('marca.tipo = 1');
$query = $this->db->get($this->table);
echo $this->db->last_query();
if ($query) {
foreach ($query->result_array() as $q) {
return $q['id'];
}
}
}
This is called in my method editfrom my controller:
...
$marca = $this->input->post('id_marca');
$modelo = $this->input->post('id_modelo');
$ano = $this->input->post('ano');
$comb = $this->input->post('combustivel');
$data['id_ano_modelo'] = $this->Modelos_model->find_id_ano_modelo($marca, $modelo, $ano, $comb);
....
source
share