Php symfony2包括类pretty sql格式化程序和将sql输出到模板
我希望使用作为symfony2库提供的漂亮的sql格式化程序。在模板页面上输出一些sql 这里包括格式化程序 /供应商/jdorn/sql格式化程序/lib/SqlFormatter 我会将其传递到细枝模板中 PageController.phpPhp symfony2包括类pretty sql格式化程序和将sql输出到模板,php,symfony,twig,Php,Symfony,Twig,我希望使用作为symfony2库提供的漂亮的sql格式化程序。在模板页面上输出一些sql 这里包括格式化程序 /供应商/jdorn/sql格式化程序/lib/SqlFormatter 我会将其传递到细枝模板中 PageController.php $queryBaseSQL = "SELECT * FROM exampleTable WHERE 'this' = 1 "; return $this->render('sjQueryBundle:Page:index.html.twig',
$queryBaseSQL = "SELECT * FROM exampleTable WHERE 'this' = 1 ";
return $this->render('sjQueryBundle:Page:index.html.twig', array(
'queryBaseSQL' => $queryBaseSQL
));
我希望能把它叫做“在树枝里面”,比如“在哪里”
(index.html.twig)
细枝:
细枝:
这很有效,谢谢-我会把它标记为正确答案。|raw是做什么的?为什么需要在SqlFormatter之前加前缀?如果使用SqlFormatter(不是\SqlFormatter),它会在命名空间中搜索SqlFormatter类(例如Acme\DemoBundle\Controller\SqlFormatter)|raw是指Twig不会在变量中转义HTML。这很有效,谢谢-我会将其标记为正确答案。|raw是做什么的?为什么需要在SqlFormatter之前加前缀?如果使用SqlFormatter(不是\SqlFormatter),它会在命名空间中搜索SqlFormatter类(例如Acme\DemoBundle\Controller\SqlFormatter)|raw是指细枝不会在变量中转义HTML。
{{ sqlFormatter::format(queryBaseSQL) }}
$queryBaseSQL = "SELECT * FROM exampleTable WHERE 'this' = 1 ";
return $this->render('sjQueryBundle:Page:index.html.twig', array(
'queryBaseSQL' => \SqlFormatter::format($queryBaseSQL);
));
{{ queryBaseSQL|raw }}