0
When doing the brand search through the input post, I need to list all products that contain the selected brand id. Below is my passage.
$marca = $this->input->post('marca');
$marca = explode(',', $marca);
if (count($marca) > 0) {
$i = 0;
foreach ($marca as $row) {
$i++;
if ($row !== "") {
if ($row !== "0") {
$query[] = $row;
$this->db->where_in(' marca_id ', $query);
}
}
}
}
With this section only list if in the field marca_id
has an integer number, I know I have to use the function json_decode
, but I can’t get the expected result.
$marca
has json? what is its structure?– rray
In this case the $brand does not yet have the json
– Gomes
No, I need to go through the tag fields and check if there is the id of the selected tag. if there should be a product
– Gomes
Then the json and the
$i
nothing related to the question? just do the direct consultation at the bank then– rray
exact, but how to verify tag ids within the tag?
– Gomes
Could you alter this bank structure? I believe it would be "but appropriate" to work with a single value in the marca_id field, i.e., avoid "multivariate" columns. Otherwise, you will have to return all the column records, go through a loop and fetch the ID, this may cost more in computational terms. Otherwise, a "Gambi" would be you give a like by = "%'id'%"
– Fábio Jânio
in fact, I had already done using two tables where I do relationship by Ids, but I thought using only one table would be easier...
– Gomes