method getCreateConstraints documentation in bbn\Db\Languages\Sqlite
function(string $table, array $model = NULL)
  {
    $st = '';
    if (!empty($model)) {
      if ($last = count($model)) {
        $st .= 'ALTER TABLE '.$this->escape($table).PHP_EOL;
        $i   = 0;
        if (!is_array($model[0])) {
          $constraints[] = $model;
        }
        else{
          $constraints = $model;
        }
        foreach ($constraints as $name => $key) {
          X::log($key, 'vito');
          $i++;
          $st .= '  ADD '.
            'CONSTRAINT '.$this->escape($key['constraint']).
            (!empty($key['foreign_key']) ? ' FOREIGN KEY ('.$this->escape($key['columns'][0]).') ' : '').
            (!empty($key['unique']) ? ' UNIQUE ('.$this->escape($key['ref_table'].'_'.$key['columns'][0]).') ' : '').
            (!empty($key['primary_key']) ? ' PRIMARY KEY ('.$this->escape($key['ref_table'].'_'.$key['columns'][0]).') ' : '').
            'REFERENCES '.$this->escape($key['ref_table']).'('.$this->escape($key['columns'][0]).') '.
            ($key['delete'] ? ' ON DELETE '.$key['delete'] : '').
            ($key['update'] ? ' ON UPDATE '.$key['update'] : '').
            ($i === $last ? ';' : ','.PHP_EOL);
        }
      }
    }
    return $st;
  }
  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