Last month I was dealing some
PHP issues on my recent project and I finally came to an understand of what was going on. In short, I would run a SQL and have PHP return the value for the result, only to find out that the result wasn't what I expected. The gaff I made reflects on my lack of understanding of comparison operators. Having lived in an Oracle SQL world for nearly two decades, I used SQL to troubleshoot other peoples data issue by writing code to tease out problems. When I needed to make an exact math on data, I would use the equals sign to get that record I was looking for. However, in PHP land, using the equals sign is how you SET a variable. If you want to find a match for something, you use two equal signs (==).
else if ($variable == '3')
In the above situation, the double equal translates to ," If the variable is equal to 3, then its true"
The transition in compassion operators between SQL to PHP can be nerve racking as you have to switch "logic" hats while writing code in the same damn file. The SQL and the PHP sit side by side, yet the use of the operator has different meaning. You live, you learn!
No comments:
Post a Comment