"<<<____SQL" ??

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Live24x7
Forum Contributor
Posts: 194
Joined: Sat Nov 19, 2011 9:32 am

"<<<____SQL" ??

Post by Live24x7 »

Now that i have started exploring php database class libraries like PDO, have been noticing a term like "<<<____SQL"
What is that ?

Code: Select all

    $sql = <<<____SQL
     CREATE TABLE IF NOT EXISTS `ticket_hist` (
       `tid` int(11) NOT NULL,
       `trqform` varchar(40) NOT NULL,
       `trsform` varchar(40) NOT NULL,
     ) ENGINE=ARCHIVE COMMENT='ticket archive'; 
thanks
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: "<<<____SQL" ??

Post by Benjamin »

Live24x7
Forum Contributor
Posts: 194
Joined: Sat Nov 19, 2011 9:32 am

Re: "<<<____SQL" ??

Post by Live24x7 »

thnks took a look at it :?

What i could understand -

this is used for is to write strings spanning multiple lines and is capable of parsing

also

Nowdocs are to single-quoted strings (no parsing) what heredocs are to double-quoted strings (parsing).
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: "<<<____SQL" ??

Post by Christopher »

Yes, it is a way to assign strings without using quotes. I recall that quotes also work with multi-line values.
(#10850)
Live24x7
Forum Contributor
Posts: 194
Joined: Sat Nov 19, 2011 9:32 am

Re: "<<<____SQL" ??

Post by Live24x7 »

thats right quotes do work in multiple lines.

so heredocs is just a larger and more clearly visible alternative to double quotes - if i may say
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: "<<<____SQL" ??

Post by Celauran »

And obnoxious. The closing delimiter must be at the beginning of a line, wrecking your code formatting.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: "<<<____SQL" ??

Post by Christopher »

Now there's a man who takes his indenting seriously! :) :drunk:
(#10850)
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: "<<<____SQL" ??

Post by Benjamin »

I'm with Celauran on that one. Drives me nuts!!
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: "<<<____SQL" ??

Post by Christopher »

Another member of the Indention Squad! :drunk:
(#10850)
Post Reply