|
Posted by Rik Wasmus on 12/01/07 02:05
On Sat, 01 Dec 2007 00:09:36 +0100, Shelly =
<sheldonlg.news@asap-consult.com> wrote:
>> I'm not entirely sure (as I use a MySQL library to ease the task), bu=
t
>> try doing something like "$queryresult =3D mysql_query($sql30daycheck=
)"
>> first and doing mysql_num_rows($queryresult).
>
> I was going to make the same suggestion.
>
> This reminded me of what I call the C programmer's "Name That Tune" =
> complex.
>
> I can code that in 5 lines.
> I can do it in 4 lines.
> It would only take me 3 lines .
> -- Write that code!
>
> (For those not old enough, there was a show called Name That Tune and
> contestents bid on how few notes they would need to name the tune). T=
hat
> kind of C programmer would put everything into the for loop so that
> everything was on one line. It was a debugging -- and code reading --=
> nightmare. I always found it better to use 2,3,4 or 5 lines or whatev=
er =
> it
> took so that I could put breakpoints in and readily trace what was goi=
ng =
> on
> to debug a problem.
Indeed, when efficiency of several possible solutions to a problem are =
close, please, pleasego for the most legible one. Number of lines are no=
t =
a way to determine efficiency.
> I would also have written his query as:
>
> $sql30daycheck =3D "SELECT * FROM cgttransactions WHERE ".
> "companyid=3D" . $impcompanyid . " AN=
D ".
> "selldatetime IS NOT NULL AND " . "
> "bbprice IS NULL AND " .
> "selldatetime >=3DDATE_SUB('" . =
> $impdatetime.
> "', INTERVAL 30 DAY) " .
I would never do that. A query is one string, _with_ possible linebreaks=
, =
and MySQL (if thats the flavour of your choice, which it usually is) wil=
l =
tell you on which line the error was if there was any. Quite a handy =
feature I'd say.
Can someone please explain this nonsense about not wanting linebreaks in=
=
strings when they're perfectly legal (and in this case quite handy), and=
=
concatinating further on other lines? HTML disregards whitespace like th=
at =
(save a few issues with UA's, in which case you just open/close the tags=
=
on another line). I know it's the default of the IMHO unsuited for PHP u=
se =
Eclipse, which is one editor which has so many problems with my deault =
coding style (and is quite bloated Java). It really was the final turn-o=
ff =
for me (there are many, many other reasons) not to use that one. Yes, I =
=
know I can change it in the settings.
Then again, I'm posting this 'cooling down' after a night out, so please=
=
disregard any spelling errors and wrong assumptions.
-- =
Rik Wasmus
[Back to original message]
|