This topic is locked
[SOLVED]

 Keys[] array in EDIT page is empty??

5/4/2012 11:21:33 AM
PHPRunner General questions
B
b.emanuele author

Hi all, I have set up master-detail tables.

The master table has a key-field called "id" (integer, autoincrement, the db is SqlServer 2005).

I've populated a new record with some data and obviously the "id" (that is an autoincrement).

In the EDIT page I've created a button that update some other fields in the master table.
The problem is that when i test the $keys["id"] array in my code, behind the button, it seems to be empty!
Phprunner 6.0 build 10638
Please help me!

Thanks!
This is the code behind the button:
function OnBefore(params,ctrl)

{

ctrl.setMessage("Sending request to server...");

}
function OnServer($params,$result,$keys)

{

global $dal;

if ($keys["id"])

{

global $dal;

$masterTbl = $dal->Table("myTable");

$masterTbl->Param["id"] = $keys["id"];

...

$masterTbl->Update();

$result["txt"] = "Record modified";

}

}

Sergey Kornilov admin 5/4/2012

Post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program. We'll be glad to assist.

B
b.emanuele author 5/7/2012



Post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program. We'll be glad to assist.


I have modified the key field name of the details table and now...it WORKS!
Master table

----------------------

id (PK,int,auto-incr)

...(other fields)
Details table (WONT WORK)

-------------------------

id (PK,int,auto-incr)

masterTableId (int)

...(other fields)
Details table (THIS WAY IT WORKS!)

-----------------------------------

detailsTableId (PK,int,auto-incr)

masterTableId (int)

...(other fields)
@admin

It seems that PHPRunner have a bit of confusion if the key field name in the master table and the key field name in the details table are the same.
Ema

B
b.emanuele author 5/8/2012

I think there is another issue and I don't know how is linked to the previous issue.

I have set different name for master key field and foreign key field: the $keys[] array is blanked if I have checked the "Display child record on" -> "Edit page" in the "Table link properties".

If I uncheck the "Display child record on" -> "Edit page" the $keys[] array is filled with my primary key ID!
You can try this yourself setting up a new project with a demo database, i've tried with Cars db, importing only carsmake (master) and carscars (details) tables linking them by the Make field.

Put a button on the edit page of carsmake and onServer function put a code like this:

$result["txt"] = var_export($keys, true);
This will act as debug, printing the $keys array content into the browser.
Build the site with the "Display child record on" -> "Edit page" UNCHECKED, click the button and in my case the $keys array contained the real id of the record.

Build the site with the "Display child record on" -> "Edit page" CHECKED, click the button and the $keys array is empty.