method createTable documentation in bbn\Db\Languages\Pgsql
function($table_name, array $columns, array $keys = NULL, bool $with_constraints = false, string $charset = 'utf8', string $engine = 'InnoDB')
  {
    $lines = [];
    $sql   = '';
    foreach ($columns as $n => $c) {
      $name = $c['name'] ?? $n;
      if (isset($c['type']) && bbn\Str::checkName($name)) {
        $st = $this->colSimpleName($name, true) . ' ' . $c['type'];
        if (!empty($c['maxlength'])) {
          $st .= '(' . $c['maxlength'] . ')';
        } elseif (!empty($c['values']) && \is_array($c['values'])) {
          $st .= '(';
          foreach ($c['values'] as $i => $v) {
            if (Str::isInteger($v)) {
              $st .= bbn\Str::escapeSquotes($v);
            }
            else {
              $st .= "'" . bbn\Str::escapeSquotes($v) . "'";
            }
            if ($i < count($c['values']) - 1) {
              $st .= ',';
            }
          }
          $st .= ')';
        }
        if (empty($c['null'])) {
          $st .= ' NOT NULL';
        }
        if (isset($c['default'])) {
          $st .= ' DEFAULT ' . ($c['default'] === 'NULL' ? 'NULL' : "'" . bbn\Str::escapeSquotes($c['default']) . "'");
        }
        $lines[] = $st;
      }
    }
    if (count($lines)) {
      $sql = 'CREATE TABLE ' . $this->tableSimpleName($table_name, true) . ' (' . PHP_EOL . implode(',' . PHP_EOL, $lines) .
        PHP_EOL . ');';
    }
    return $sql;
  }
  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