method getInsert documentation in bbn\Db\Languages\Sql
Generates a string for the insert from a cfg array.
function(array $cfg)
  {
    $fields_to_put = [
      'values' => [],
      'fields' => [],
    ];
    $i             = 0;
    foreach ($cfg['fields'] as $i => $f) {
      if (isset($cfg['available_fields'][$f], $cfg['models'][$cfg['available_fields'][$f]])) {
        $model  = $cfg['models'][$cfg['available_fields'][$f]];
        $csn    = $this->colSimpleName($f);
        if (isset($model['fields'][$csn])) {
          $fields_to_put['fields'][] = $this->colSimpleName($f, true);
          if ($cfg['values_desc'][$i] && ($cfg['values_desc'][$i]['type'] === 'exp')) {
            $fields_to_put['values'][] = $cfg['values'][$i][1];
          }
          else {
            $fields_to_put['values'][] = '?';
          }
        }
        else {
          $this->error(X::_("Error! Impossible to find the model for %s", implode(', ', $cfg['tables'])), false);
        }
      } else {
        $this->error(X::_("Error! The column '%s' doesn't exist in %s", $f, implode(', ', $cfg['tables'])), false);
      }
      $i++;
    }
    if (count($fields_to_put['fields']) && (count($cfg['tables']) === 1)) {
      return 'INSERT ' . (!empty($cfg['ignore']) ? $this->getIgnore() : '') . 'INTO ' . $this->tableFullName(current($cfg['tables']), true) . PHP_EOL .
        '(' . implode(', ', $fields_to_put['fields']) . ')' . PHP_EOL . ' VALUES (' .
        implode(', ', $fields_to_put['values']) . ')' . PHP_EOL;
    }
    return '';
  }
  Generates a string for the insert from a cfg array. BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way
  
  
    
    
      
        
        
      
    
    
    
      
      
      
      
      
        
          
          
          
          
          
          
          
          
            
              
                
              
            
            
              
              This website uses cookies to ensure you get the best experience on our website.                
                
              
              
                
                
              
             
           
          
          
          
            
            © 2011-2025 
BBN Solutions