• Question:

    How do you declare the relation between this ‘level’:

    array('level' => 3, 'url_parameter' => '_year', 'option_title' => __('-- Year --', 'ymm-search'))

    And These 2 different columns in the database? :

    year_from , year_to

    is this line in db.php what builds the relation between them? :

    else if ($nextlevel == 3) {              
            $select = "SELECT DISTINCT year_from, year_to FROM {$this->_mainTable} WHERE make = '".esc_sql($params[0])."' AND model = '".esc_sql($params[1])."' AND engine = '".esc_sql($params[2])."' AND (year_from != 0 OR year_to != 0) {$whereProducts}";      
            $rows = (array) $this->_wpdb->get_results($select, ARRAY_A);
    
            $y = array();
            
            foreach ($rows as $r) {
    
              $from = (int) $r['year_from'];
              $to = (int) $r['year_to'];	
    
              if ($from == 0){
                $y[$to] = 1;          
              } elseif ($to == 0){
                $y[$from] = 1;
              } elseif ($from == $to){
                $y[$from] = 1;
              } elseif ($from < $to){          	
                while ($from <= $to){
                  $y[$from] = 1;
                  $from++;
                }            
              }
            } 
    
            krsort($y);
                      
            $values = array_keys($y);
Viewing 1 replies (of 1 total)
  • Plugin Author Pektsekye

    (@pektsekye)

    Hello,

    ‘level’ => 3
    It means the drop-down select in the search box on the front-end.

    year_from , year_to
    It is how the year data is saved in the database.

    The code that you mention from the “db.php” file converts the data from two columns into a single ordered list of all selectable years for the current selected make and model.

    PS: The year is saved into the database with two columns to preserve the format that is used the .csv file. So that it is possible to import/export data directly into the database table.

    Stanislav

Viewing 1 replies (of 1 total)
  • The topic ‘What’s the relation between them?’ is closed to new replies.