This topic is locked

BEFORE SQL QUERY AND CHILD COUNT

9/16/2009 6:41:21 PM
PHPRunner General questions
G
garethp authorDevClub member

Hi
Having real problems with this and driving me insane.
I have a master-detail setup on 2 tables. On the detail table I have a before sql event for selection as follows...

$strWhereClause = whereAdd($strWhereClause,"activity_users.username ='".$_SESSION["UserID"]."' and activity_users.approval=1");


The details preview of from the master table list page ignores this sql and too many records are shown, but I can overcome this by adding the selection code directly to the details preview generated file - shown in coloured font.

if($mastertable=="activityIII")

{ $where ="";

$where.= GetFullFieldName("activity")."=".make_db_value("activity",$_SESSION[$strTableName."_masterkey1"])];

}


This corrects the number of lines shown and also the total record count on the details preview - which is now correct.
However, I can not find any way to get the childnumber on the master table list page to show the correct number of records. This also ignores the sql event added.
I have tried ammending the code in the list page php file but with no luck.
Please can you help before I throw my computer out of the window! This is driving me mad!!!!!!
Many thanks

J
Jane 9/17/2009

Hi,
edit generated master ..._list.php file for this purpose.

Find this code:

if (strlen($securityClause))

$subQ .= " WHERE ".whereAdd($sqlWhere, $securityClause);

elseif(strlen($sqlWhere))

$subQ .= " WHERE ".whereAdd("",$sqlWhere);



and replace it with this one:

if (strlen($securityClause))

$subQ .= " WHERE ".whereAdd($sqlWhere, $securityClause." and activity_users.username ='".$_SESSION["UserID"]."'");

elseif(strlen($sqlWhere))

$subQ .= " WHERE ".whereAdd("",$sqlWhere." and activity_users.username ='".$_SESSION["UserID"]."'");

else

$subQ .= " WHERE activity_users.username ='".$_SESSION["UserID"]."'";
G
garethp authorDevClub member 9/17/2009

Jane
You are amazing. You have saved the life of my computer - and I was close to jumping as well!!!!!
Thanks so so so much
Gareth