Query, add clause, query again without using original $result
-
Straight cut and paste PHP code snippet that SVN blame assigns to a couple of our more senior DB guys... who normally make all kinds of sense, but this is the shop's semi-official "bodge, hack, and kludge" project!
$result = mysql_query( $sql ) or die("MySQL error: " . mysql_error() ); $sql .= " ORDER BY id DESC"; $result = mysql_query( $sql ) or die("MySQL error: " . mysql_error() );
-
@swiers said:
Straight cut and paste PHP code snippet that SVN blame assigns to a couple of our more senior DB guys... who normally make all kinds of sense, but this is the shop's semi-official "bodge, hack, and kludge" project!
$result = mysql_query( $sql ) or die("MySQL error: " . mysql_error() );
$sql .= " ORDER BY id DESC"; $result = mysql_query( $sql ) or die("MySQL error: " . mysql_error() );
I'll reply as soon as I find out if the reply function is working.
-
@swiers said:
Straight cut and paste PHP code snippet that SVN blame assigns to a couple of our more senior DB guys... who normally make all kinds of sense, but this is the shop's semi-official "bodge, hack, and kludge" project!
$result = mysql_query( $sql ) or die("MySQL error: " . mysql_error() );
$sql .= " ORDER BY id DESC"; $result = mysql_query( $sql ) or die("MySQL error: " . mysql_error() );
I'll reply as soon as I find out if the reply function is working. And it is working! I'll reply now.
What a WTF that WTF is!
-
Even better, the original $sql involved joining 6 different tables, with a left join about halfway through the chain, and the base table having a record for every order ever made on the site. The wasted query was a BIG one...
-
I can top that.
In my case, the first query was used as an IF EXISTS type deal, and the second was in a different file, included — via iframe — if thefirst query had results.
-
@swiers said:
$result = mysql_query( $sql ) or die("MySQL error: " . mysql_error() );
$sql .= " ORDER BY id DESC"; $result = mysql_query( $sql ) or die("MySQL error: " . mysql_error() );
The first query primes the cache. The second one simply sorts the cache.Oh wait, MySQL isn't that smart? Oh well.
-
What kind of retards does your company employ? Also mysql_query? Not even mysqli_query?
You ruined Christmas.
-
To be fair, that's not from production code - its from a new version of an old page that is only (currently) on the dev server. Not saying it would have been fixed (think its slated for QA next week) but it's a pretty basic cut & paste mistake on a WIP project, not a design pattern...