"Fossies" - the Fresh Open Source Software Archive

Member "phpMyAdmin-5.1.0-all-languages/libraries/classes/Controllers/Database/SqlFormatController.php" (24 Feb 2021, 483 Bytes) of package /linux/www/phpMyAdmin-5.1.0-all-languages.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 <?php
    2 
    3 declare(strict_types=1);
    4 
    5 namespace PhpMyAdmin\Controllers\Database;
    6 
    7 use PhpMyAdmin\SqlParser\Utils\Formatter;
    8 use function strlen;
    9 
   10 /**
   11  * Format SQL for SQL editors.
   12  */
   13 class SqlFormatController extends AbstractController
   14 {
   15     public function index(): void
   16     {
   17         $params = ['sql' => $_POST['sql'] ?? null];
   18         $query = strlen((string) $params['sql']) > 0 ? $params['sql'] : '';
   19         $this->response->addJSON(['sql' => Formatter::format($query)]);
   20     }
   21 }