This topic is locked
[SOLVED]

 Masterkey1 for non numeric flields

10/29/2016 7:59:38 AM
PHPRunner General questions
A
andreas.knab author

Hi Together,
maybe someone can give me a hint. I can copy fields from master to Detail using code like this:

global $dal, $strTableName;
if ($_SESSION[$strTableName."_masterkey1"])
{
$tbldoc = $dal->Table("dok_adm_basis");
$rs = $tbldoc->Query("id=".$_SESSION[$strTableName.
"_masterkey1"],"");
if ($data = db_fetch_array($rs))
{
$_SESSION["x"] = $data["id"];

$_SESSION["xx"] = $data["docname"];
}
}
Master key field is "id" in Detail I fill in master id and master docname in x and xx with $_SESSION.
As Long I use numeric ID to link master and Detail field everything works perfect.

When I use the varchar docname field to link master and Detail i get an SQL error.

I changed this line of code to achieve this:



$rs = $tbldoc->Query("docname=".$_SESSION[$strTableName.
"_masterkey1"],"");
When I take a look at the error the SQL statement is without quotes.

So I tried hours to find out where to position the quotes without being successful.
Can someone pls help here.
THX

Andreas
Short update: I'm not sure anymore if this is only a Quote issue....



phpr9 mysql ...still a coding beginner

A
andreas.knab author 10/30/2016

Hi,

as I'm still learning the answer is still interesting.
Nevertheless I found a Workaround (or a better solution?)for this .
In before Display Event I use:
$data = $pageObject->getMasterRecord();

$_SESSION["id"]=$data["id"];
thx

Andreas