SQL style query

When I debug my program, I have a lot of big SQL queries as output below, and I parse them. Is it possible to set the request style as follows:

SELECT * FROM users LEFT JOIN profile ON users.id = profile.id WHERE user_id = 2 to

 SELECT * FROM users LEFT JOIN profile ON users.id = profile.id WHERE user_id = 2 

so would it be easier to complete the request? Is there anything I could do without a lot of code in PHP? Or maybe there is a jQuery plugin for this?

+4
source share
2 answers

I think sql-formatter can just do what you need. This is a fairly simple PHP class.

The GitHub repository is here: https://github.com/jdorn/sql-formatter

+2
source

here sql beautifier This will decorate queries, and your query after decoration will look like this.

  SELECT * FROM users LEFT JOIN profile ON users.id = profile.id WHERE user_id = 2 

It is better to quickly read and understand all the steps.

+2
source

Source: https://habr.com/ru/post/1493856/


All Articles