Anybody tell me the best way to indent/format queries in PHP

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Perhaps it's a good idea to centralize all your SQL queries in a separate file.. Similar to gettext...
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

I do agree that backticks are very important,,,I just forgot them as I was thinking more on the query format rather the query itself.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

raghavan20 wrote: It's always a pain to indent in this kind of situation in editors other than Dreamweaver where you have to use so many tabs to get the query in desired format.
Many editors will retain your indent for you. Crimson does, Zend does, Kate does...

Note: You can still use heredoc on your example, it's just that the ending delimiter needs to be right up against the margin wich can make the flow of the indentation in your code look a bit off. I agree that it doesn't look very attractive, but I still use heredoc a lot even when nested into the code, since it's just so nice to work with, esp. if you're embedding something like JavaScript into your source.
Deemo
Forum Contributor
Posts: 418
Joined: Sun Jan 18, 2004 11:48 am
Location: Washington DC

Post by Deemo »

what is the advantage of using backticks?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Deemo wrote:what is the advantage of using backticks?
you can use reserved words as column, table, and database references..
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

<edit>Nothing to see here, move along please...</edit>
Post Reply