This topic is locked

Lookup wizard $_SESSION where clause

7/27/2011 7:35:26 AM
PHPRunner General questions
W
webdino author

Hello

I try to manipulate my select dropdown where clause
event BeforeShowEdit looks like this

$_SESSION["CustomId"]=$_REQUEST['editid']
var_dump of $_SESSION says ["CustomId"]=> &string(1) "2"
my where clause looks like this:

"Kunde <>= " . $_SESSION["CustomId"]
is there an ampersand false?
Test of lookup says "retrieve no data, show all data"

W
webdino author 7/27/2011

I try more examples but no from these works
when I try " Kunde = '2'
-> then the where clause gets correct value
But when I write

" Kunde = '".$_SESSION[CustomId]."'
-> the where clause gets not correct values and displays all values

C
cgphp 7/27/2011



"Kunde <>= " . $_SESSION["CustomId"]



it should be:



"Kunde <> " . $_SESSION["CustomId"]




" Kunde = '".$_SESSION[CustomId]."'



it should be:



" Kunde = ". $_SESSION["CustomId"] //if CustomId is an int you don't need single quote


Try to echo the session var just to be sure that it is not empty.

W
webdino author 7/27/2011

Session var echo in the event is correct
But the array from $_SESSION says that this variable is string

var_dump says
array(8) { ["OwnerID"]=> &NULL ["CustomId"]=> &string(1) "2" ["zuordnung_key"]=> &array(1) { [0]=> int(1) } ["zuordnung_sql"]=> &string(61) "SELECT ID, Kunde, Standort FROM zuordnung ORDER BY 1 ASC" ["zuordnung_where"]=> &string(0) "" ["zuordnung_order"]=> &string(15) " ORDER BY 1 ASC" ["zuordnung_arrFieldForSort"]=> &array(1) { [0]=> int(1) } ["zuordnung_arrHowFieldSort"]=> &array(1) { [0]=> string(3) "ASC" } }

C
cgphp 7/27/2011

Do an explicit cast:

$_SESSION["CustomId"] = (int)$_REQUEST["editid"];
W
webdino author 7/29/2011

I desperate :-()
Lookup wizard in where clause:

"ID = " . $_SESSION["CustomId"]
but a "hard" coded sql works

"ID =2 "
thats the content of $_SESSION- CustomId CustomID is set with value 2
array(8) { ["OwnerID"]=> &NULL ["CustomId"]=> &int(2) ["zuordnung_key"]=> &array(1) { [0]=> int(1) } ["zuordnung_sql"]=> &string(61) "SELECT ID, Kunde, Standort FROM zuordnung ORDER BY 1 ASC" ["zuordnung_where"]=> &string(0) "" ["zuordnung_order"]=> &string(15) " ORDER BY 1 ASC" ["zuordnung_arrFieldForSort"]=> &array(1) { [0]=> int(1) } ["zuordnung_arrHowFieldSort"]=> &array(1) { [0]=> string(3) "ASC" } }

C
cgphp 7/29/2011

Initialize the session var in the "Before process" event.

W
webdino author 7/29/2011

I give up
in Event Before Process

global $conn;

$strSQLExists = "select Kunde from Zuordnung where ID = ".$_REQUEST["editid1"];

$rsExists = db_query($strSQLExists,$conn);

$data=db_fetch_array($rsExists);
$_SESSION["CustomId"]=intval($data['Kunde']);
and then in lookup

"ID = " . $_SESSION["CustomId"]
But the test always says: no values returned all values are shown.

C
cgphp 7/29/2011

I have reproduced a similar scenario on my side an it works fine.
Check the name of fields and be sure to place the session var initialization code in the right event for the edit page.

W
webdino author 7/29/2011

which event do you mean?

["CustomId"]=> &int(2) is set, but there is a error, in each record the customid is identical that is wrong?

I don´t know whats my fault.
Can I do this too in a snippet? I doesnt know whats wrong.

with hard where clause the selct works fine

But which record data are there when I select for each record?
what have I done:

first:

global $conn;

$strSQLExists = "select Kunde from Zuordnung where ID = ".$_REQUEST["editid1"];

$rsExists = db_query($strSQLExists,$conn);

$data=db_fetch_array($rsExists);
$_SESSION["CustomId"]=intval($data['Kunde']);
is my array not correct? I don´t know what´s wrong when the customid at each recordset seems the same
second: I create a lookup on the field Kunde to lookup from the name where ID not equal with used ID´s

C
cgphp 7/29/2011

Webdino,
it's hard to say what's happening without seeing your actual files.

W
webdino author 7/31/2011

I try more times