Hacker News new | past | comments | ask | show | jobs | submit | egormakarov's comments login

Lets say its 2001 and you are writing some hot e-commerce stuff in plain php. You want to filter data depending on multiple fields in the submitted form. If some field is there, you add one more "AND" clause to the "WHERE", like this: if (isset($_POST['product'])) { $query .= "AND product = " . $_POST['product']; }. So in order not to check every time if the added clause is the first one you start with "WHERE 1=1 ", as "WHERE AND ..." would not work.

Php has nothing like this?

In [1]: "... WHERE " + " AND ".join(str(i) for i in range(4))

Out[1]: '... WHERE 0 AND 1 AND 2 AND 3'

Very strange.


This will produce broken SQL on empty clauses list. Very strange.

You're quite right, but this is easily fixed. That doesn't change my question, since something like this is much easier that the other logic.

The easiest fix for this is the "WHERE 1=1" or "WHERE true"

I get how this isn't good. But how else would you handle multi-field filtering, keep all the ANDs and use (product_id = $1 OR $1 IS NULL) so the unset filters are no-op? That's ok as long as the query planner is smart enough.

It's other way around, with headwind you will get less distance over ground


this "supercommute" word has some positive vibes to it, how about "will shittycommute" or something like that instead


"super-pollute"

As most things CEO's do it will be a flippant display that will last about as long as a lettuce out of the fridge. However, those below will be expected to show evidence the rules are followed because there's nothing quite like cascading punishment, because that's the fun part of being a shitty boss, watching people suffer because they say so.

Look for teams that are flexible about remote work, those are the bosses you want to work for in this current day and age.

Every time I read one of these "back on site to do work" style posts, yet we'll offshore at the drop of a hat, it infuriates me as I can't see sense in the logic.


About 100kb of carefully crafted yaml configs


The money could be then invested into a testarossa and a pet alligator


As nice as the Testarossa is, I would probably go for the 365 GTS/4 instead.


Does the aligator have lazers?


That reminds me about german version of TES Oblivion with its "Schw. Tr. d. Le.en.-W." for "small potion of healing"


Nicely summarized in this Poorly Drawn Lines episode https://poorlydrawnlines.com/comic/nice-notebook/


LOL, I'm the bird! LOL


MISRA-ready!


the comparison with car seat belts is not that good. you dont need to schlep around your seat belt with you any time you leave the car.


but then your date is also sweaty, and both of you are in good shape!


And if one of the people turns out to be a creepy perv, the other one can leave without having to depend on them for a ride home in their car.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: