Ask a question about PHP assignment judgment
Just contact PHP, in a MySQL class to see such a sentence
$condition = $condition? ' WHERE '. $condition: NULL
Not too clear what meaning, ask you can explain.
I personally interpret him as: "where". $condition is empty, then the ' where '. $condition assigned to $condition, on the contrary, the $condition= $condition, do not know is right or wrong, but also hope that the great God come to teach!!
------Solution--------------------
Damn, upstairs is wrong!
If the ' where ' $condition is empty, the ' where ' $condition is assigned to $condition, whereas the $condition= $condition
=
If the $condition is not empty, the ' where ' $condition assigned to $condition, whereas the $condition=null
------Solution--------------------
This is the flattening of an SQL statement.
For example, if the user does not set a match condition, then it is
SELECT * FROM TableName;
If there is a set condition, that is, $condition is not empty.
SELECT * FROM TableName WHERE $condition;
------Solution--------------------
$a? $b: $c
PHP's ternary operator.
If $ A is true, the value of the expression is $b, and if False, the expression value is $c.
------Solution--------------------
PHP Code
$condition = $condition? ' WHERE '. $condition: null//is equivalent to if ($condition) { $condition = ' where '. $condition;} else{ $condition = NULL;}