Data Filtering in Codeigniter, Mysql

0

I'm doing a search and filtering it with $this->input->get('tags') .

The problem I have is that the data with which I will filter is in a table from 1 to many, where one can have multiple data.

The tables I have in the database are:

  • metadata_descriptors = where I store the name of the category to which it belongs by saying in this case that I do the filters of 'TAGS', 'CATEGORIES' (Here I have: idDescriptor, name)
  • metadata_values = where I store the descriptor values, where 1 descriptor can have multiple values (Here I have: id, idDescriptor, idObject, value)
  • Objects = I store the objects and their basic information (Here I have: idObject, title, etc)
  • This would be my model for the search of the object, here I am still not filtering because the values are concatenated.

            $where = array('Year Created', 'Thumbnail Patch', 'Tags', 'Categories');
            $this->db->select('objects.*, GROUP_CONCAT(mvalues.value SEPARATOR ", ") as value, GROUP_CONCAT(mdescriptor.name SEPARATOR ", ") as name')
            ->from('objects')
            ->join('metadata_values mvalues','mvalues.idObject = objects.idObject')
            ->join('metadata_descriptors mdescriptor', 'mvalues.idDescriptor = mdescriptor.idDescriptor');
            $this->db->where('objectType', 'EMBED');
            $this->db->where_in('mdescriptor.name', $where);
            $this->db->group_by('objects.idObject');
            $this->db->order_by($sort, $by);
            $this->db->limit($limit, $page);
            $result = $this->db->get();
            return $result->result();
    

    And this is the result of the previous model (showing only where the values that interest me are).

    If the URL is the ?tags=Adornment Should only show me the results that have tags and their value is adornment but how are they concatenated as I could do in this case?

        
    asked by Arielperez 11.09.2018 в 23:19
    source

    0 answers