This topic is locked

edit page error

2/26/2008 1:57:39 PM
PHPRunner General questions
D
dakk author

I have 3 tables. I use a join to display the 3 tables on the list page good. On the edit page I get the error "ociexecute() [function.ociexecute]: ORA-00904: "AC_CG22_NUM": invalid identifier" when I change a piece of data and save. If I remove the field "AC_CG22_NUM" from the edit form it saves fine.
I want to edit the 3 tables from one edit form. What is the proper technique and how?
Thanks

Oracle 10G, phpRunner 4.1

A
alang 2/26/2008

PHPR uses a primary table for list/edit/add etc even though you may join other fields from other tables in the SQL. You need to use code in the "Before record updated" event to ensure that all fields NOT in this primary table in the $values array are "unset" before calling "return true;". If you also want to update these "joined" fields in your database (in other tables), you need to do this manually in the event code prior to unsetting them.

D
dakk author 3/5/2008

PHPR uses a primary table for list/edit/add etc even though you may join other fields from other tables in the SQL. You need to use code in the "Before record updated" event to ensure that all fields NOT in this primary table in the $values array are "unset" before calling "return true;". If you also want to update these "joined" fields in your database (in other tables), you need to do this manually in the event code prior to unsetting them.


I've struggled with this thing. After a hard effort here is what I have. It seems to have a problem with the sql. I can't see a problem.
$conn=db_connect();

$strUpdate = "update ARCHIVE_CG22 set AC_CG22_NUM=".$values["AC_CG22_NUM"]."where AC_MPC_ID_FK=".$values["AM_MPC_ID_PK"];

$stmt = oci_parse($conn, $strUpdate);

oci_execute($stmt, OCI_DEFAULT);

oci_commit($conn);

unset($values["AC_CG22_NUM"]);

return true;

A
alang 3/5/2008

I am not familiar with the oci_.. commands but:

  1. Ensure you end up with singel quotes around the actual values in the SQL ie.
    $strUpdate = "update ARCHIVE_CG22 set AC_CG22_NUM='".$values["AC_CG22_NUM"]."' where AC_MPC_ID_FK='".$values["AM_MPC_ID_PK"]."'";
  2. Use echo or whatever on $strUpdate and check the SQL generated will work using another tool like SQLyog
  3. Assume the record does already exist in the ARCHIVE_CG22 table. The result of my point #2 above should verify that also.

D
dakk author 3/6/2008

I am not familiar with the oci_.. commands but:


  1. Ensure you end up with singel quotes around the actual values in the SQL ie.
    $strUpdate = "update ARCHIVE_CG22 set AC_CG22_NUM='".$values["AC_CG22_NUM"]."' where AC_MPC_ID_FK='".$values["AM_MPC_ID_PK"]."'";
  2. Use echo or whatever on $strUpdate and check the SQL generated will work using another tool like SQLyog
  3. Assume the record does already exist in the ARCHIVE_CG22 table. The result of my point #2 above should verify that also.


Thanks AlanG,

I had the quotes messed up. Now it doesn't error. I understand now.
If I have the field AM_MPC_ID_PK on the visual editor Edit Page set as a text field the update sql works. If I change it to Readonly (this is a primary key field) then the value isn't passed to the sql. Actually I don't want the primary key value displayed on the edit page at all. The edit page seems to have the value of the data row primary key (AM_MPC_ID_PK) ready to be accessed. My question is

  1. what syntax will pass this value in the sql (highlighted in bold) without using a text box on the Edit Page and
  2. as an alternative, why doesn't text box set as Readonly pass the value to the sql?
    $strUpdate = "update ARCHIVE_CG22 set AC_CG22_NUM='".$values["AC_CG22_NUM"]."' where AC_MPC_ID_FK='".$values["AM_MPC_ID_PK"]."'";
    I'll keep trying different stuff, but if you or anyone knows I'll be glad to accept your generous help.

D
dakk author 3/6/2008

found the answer changed .$values to .$oldvalues which is

// $oldvalues - Array object with existing data record content
that was able to put the record value into the sql.