I'm making a query dynamically like this:
$query = "SELECT u.*
FROM users u
WHERE date_time > unix_timestamp(DATE_SUB(now(), INTERVAL 1 $range))";
Also $range
contains a word like this:
switch ($_GET['range']){
case "week":
$range = "WEEK";
case "month":
$range = "MONTH";
case "year":
$range = "YEAR";
case "ALL":
$range = <I don't know what should I put here to get the expected result>;
}
As I've said above, I want to set something as $range
value to make the WHERE
clause something like WHERE 1
. How can I do that?
$range
somewhere else too. I cannot do what you've suggested. – stack$query->addWhere()
... Otherwise the string concatenation can get messy fast. – ficuscr