"?string", "table" => "string", "schema" => "?array", "cols" => "?array", "suffix" => "?string", ]; static function isa(string $sql): bool { #XXX implémentation minimale return preg_match("/^create(?:\s+table)?\b/i", $sql); } static function parse(array $query, ?array &$bindings=null): string { #XXX implémentation minimale $tmpsql = self::merge_seq($query); self::consume('create(?:\s+table)?\b', $tmpsql); $sql = ["create table"]; if ($tmpsql) $sql[] = $tmpsql; ## préfixe $prefix = $query["prefix"] ?? null; if ($prefix !== null) $sql[] = $prefix; ## table $table = $query["table"] ?? null; if ($table !== null) $sql[] = $table; ## columns $cols = $query["cols"] ?? null; if ($cols !== null) { $index = 0; foreach ($cols as $col => &$definition) { if ($col === $index) { $index++; } else { $definition = "$col $definition"; } }; unset($definition); $sql[] = "(\n ".implode("\n, ", $cols)."\n)"; } ## suffixe $suffix = $query["suffix"] ?? null; if ($suffix !== null) $sql[] = $suffix; ## fin de la requête return implode(" ", $sql); } }