pkrawetz
Posts: 77
|
| Posted: 03/08/2008, 9:44 AM |
|
CCS Version 4.00.00.03
I set up a BeforeBuildSelect event for an editable grid.
BeforeBuildSelect code:
if (CCGetGroupId() <> 2) {
if ($PERSONNEL_LIST->DataSource->Where <> "") {
$PERSONNEL_LIST->DataSource->Where .= " AND ";
}
else
{
$PERSONNEL_LIST->DataSource->Where .= "PERSONNEL_ID = " . ccdlookup("PERSONNEL_ID","SECURITY","USERNAME = '" . CCGetUserId() . "'", $db);
}
}
The $this->Where value is properly set (I echoed it). The value is PERSONNEL_ID = 1.
I also echoed $this->OptimizeSQL(CCBuildSQL($this->SQL, $this->Where, $this->Order)); and the result is missing the Where value:
SELECT PERSONNEL_ID, ALTERNATE_ID, CONCAT(LAST_NAME, ', ', FIRST_NAME,' ', MIDDLE) AS NAME, STATUS, HOME_PHONE, CELL_PHONE, WORK_PHONE FROM personnel ORDER BY LAST_NAME LIMIT 0,100
I reviewed the CCBuildSQL code which was generated in common.php with the following code:
function CCBuildSQL($sql, $where = "", $order_by = "")
{
if (!$sql) return "";
if(strlen($where)) $where = " WHERE " . $where;
if(strlen($order_by)) $order_by = " ORDER BY " . $order_by;
if(stristr($sql,"{SQL_Where}") || stristr($sql,"{SQL_OrderBy}")){
$sql = str_replace("{SQL_Where}", $where, $sql);
$sql = str_replace("{SQL_OrderBy}", $order_by, $sql);
return $sql;
}
$sql .= $where . $order_by;
return $sql;
}
Now, unless I am missing something, the $where parm is set to "". Is this correct and if so, why? If I am passing a where clause, it should place that as part of the query.
|
 |
 |
mamboBROWN
Posts: 1713
|
| Posted: 04/08/2008, 11:04 PM |
|
pkrawetz
Has this been resolved??
|
 |
 |
pkrawetz
Posts: 77
|
| Posted: 04/09/2008, 4:59 AM |
|
Yes it has. If you use the custom SQL option, the BeforeBuildSelect will not execute. Frankly I think this is a bug but support said it wasn't. Even though you are using custom SQL to build the initial query, you should be able to apply predicates to the SQL statement at execution time.
|
 |
 |
wkempees
|
| Posted: 04/12/2008, 9:40 AM |
|
What they probably mean is that, when using custom SQL
you will not be able to use the $DBConnection->Where
as th SQL construct is not parsed, but your ciustom SQL is executed.
So they made the whole event obsolete, which I wonder to be a good idea.
Walter
|
|
|
 |
|