Code: Select all
$query1 = "SELECT COUNT(fldActComp)";
$query1 .= "FROM tblcontracts WHERE fldBEAnum = '{$this->bea_number}' ";
$query1 .= "AND fldActComp IS NULL ";Code: Select all
$query2 = "SELECT COUNT(fldActComp)";
$query2 .= "FROM tblcontracts WHERE fldBEAnum = '{$this->bea_number}' ";
$query2 .= "AND fldActComp IS NOT NULL ";I would write the same code this way:
Code: Select all
$query = "SELECT COUNT(fldActComp)
FROM tblcontracts WHERE fldBEAnum = '{$this->bea_number}'
AND fldActComp IS NOT NULL ";Code: Select all
$query = "SELECT COUNT(fldActComp)
FROM tblcontracts WHERE fldBEAnum = '{$this->bea_number}'
AND fldActComp IS NULL ";I have two questions:
1. Is there anything wrong with re assigning the same variable name ($query) in this manner? My logic is, even though PHP has some powerful OOP capabilities it is essentially a procedural language. When I have used the variable, it's finished with so I should be able to re assign it's value later in the code.
2. Is it really necessary to concatenate each line of the query in the manner my colleague uses? Sometimes I use Navicat to write complex SQL code that I then copy and paste between applications, it's a lot easier to copy and paste between applications if it's written the way I do it.