Example #1
0
 /**
  * Prepare fetch of rows : initializes
  * - $classes
  * - $column_count
  * - $column_names
  *
  * @param $data_store List_Data|array[]|object[]|null
  */
 private function prepareFetch($data_store)
 {
     $this->classes = [];
     $this->column_count = $this->link->getColumnsCount($this->result_set);
     $this->column_names = [];
     $this->i_to_j = [];
     $classes_index = [];
     $j = 0;
     for ($i = 0; $i < $this->column_count; $i++) {
         $this->column_names[$i] = $column_name = $this->link->getColumnName($this->result_set, $i);
         if (strpos($column_name, ':') == false) {
             $this->i_to_j[$i] = $j++;
         } else {
             $split = explode(':', $column_name, 2);
             if (!isset($this->path_classes[$split[0]])) {
                 $this->preparePathClass($split[0]);
             }
             $this->column_names[$i] = $column_name = $split[1];
             $main_property = $split[0];
             $his_j = isset($classes_index[$main_property]) ? $classes_index[$main_property] : null;
             if (!isset($his_j)) {
                 $his_j = $j;
                 $this->classes[$his_j] = $this->path_classes[$main_property];
                 $classes_index[$main_property] = $j;
                 $this->i_to_j[$i] = $j++;
             } else {
                 $this->i_to_j[$i] = $his_j;
             }
         }
         if ($data_store instanceof List_Data && substr($column_name, 0, 3) === 'id_') {
             $this->column_names[$i] = $column_name = substr($column_name, 3);
         }
         if (!isset($this->columns[$i])) {
             $this->columns[$i] = $column_name;
         }
     }
 }