method createTable documentation in bbn\Db\Languages\Sqlite

function($table_name, array $columns, array $keys = NULL, bool $with_constraints = false, string $charset = 'UTF-8') { $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){ $st .= "'".bbn\Str::escapeSquotes($v)."'"; if ($i < count($c['values']) - 1) { $st .= ','; } } $st .= ')'; } if ((strpos($c['type'], 'int') !== false) && empty($c['signed'])) { $st .= ' UNSIGNED'; } 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, false).' ('.PHP_EOL.implode(','.PHP_EOL, $lines). PHP_EOL.'); PRAGMA encoding='.$this->qte.$charset.$this->qte.';'; } 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.