RE: [PHP-DB] Is this query even possible?

From: Date: Tue, 10 Jun 2003 16:06:48 +0000
Subject: RE: [PHP-DB] Is this query even possible?
Groups: php.db 
Request: Send a blank email to php-db+get-28495@lists.php.net to get a copy of this message
> -----Original Message----- > From: Matthew Moldvan [mailto:mmoldvan@trilogyintl.com] > Sent: 10 June 2003 16:50 > > As for the line breaks, I've used SQL formatted that way before and it > hasn't cause me any problems. It's a matter of preference, but I prefer to keep my query strings as lean as possible -- bear in mind that this version: > > > $sql = "UPDATE newdacs > > > SET emailfwd='$emailfwd', > > > mformat='$mformat', > > > filter_code='$filter_code'"; will include not only the linebreaks but also all the leading whitespace on every line. Personally, I like the technique of breaking my query up logically onto multiple lines, but I also prefer not to include unnecessary whitespace in the constructed query. In addition, it seems to me that the repetitive inclusion of "$sql .= " on every line is not only distracting but also slightly inefficient, as you perform a concatenation and assignment for every line -- by using the form I showed in my previous response, you can reduce this to just a concatenation per line, and a single assignment: $sql = "UPDATE newdacs" . "SET emailfwd='$emailfwd'," . "mformat='$mformat'," . "filter_code='$filter_code'"; Of course, this is all completely IMHO, and I wouldn't say that any of the other ways of doing it is absolutely wrong. Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: m.ford@lmu.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

« previous php.db (#28495) next »