SQL where the condition receives only one word from the field value

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);
....
+4
source share
1 answer

After discussing this issue in chat, the error was resolved:

ajax, :

modelo.append('<option value=' + v.modelo + '>' + v.modelo + '</option>');

. html:

:

QQ 1.0 ACT 12V 69cv 5p

:

<option value="QQ" 1.0="" act="" fl="" 12v="" 69cv="" 5p="">QQ 1.0 ACT FL 12V 69cv 5p</option>

qoutes :

modelo.append('<option value="' + v.modelo + '">' + v.modelo + '</option>');
+2

Source: https://habr.com/ru/post/1625870/


All Articles