This topic is locked

Update Statement

3/31/2009 10:54:00 AM
PHPRunner General questions
S
scopley author

I'm trying to set up an event that will change a field value after a record has been updated. After the record is updated I want it to change the SC_REVIEW_STATUS field value to 'MODIFIED'. When I save my record it updates all the records as being modified.
I'm new to PHP and this has gotten me stumped. I've put in a echo $where; statement and it is pulling the correct primay key value so I'm not sure what I am doing wrong. Any help would be greatly appreciated.
See code below:
[codebox]$revQuery = "SELECT AF_FILE_ID_PK, SC_FILE_ID_FK FROM ARCHIVE_FILES, STATUS_CHART WHERE ARCHIVE_FILES.AF_FILE_ID_PK = STATUS_CHART.SC_FILE_ID_FK";
$revStat = oci_parse($conn, $revQuery);

oci_execute($revStat);

while ($row = oci_fetch_array($revStat))

{

$pkid = $row[0];
$strUpdate = "update STATUS_CHART set SC_REVIEW_STATUS='MODIFIED' where SC_FILE_ID_FK='$pkid'";
$stmtupd = oci_parse($conn, $strUpdate);

oci_execute($stmtupd, OCI_DEFAULT);

oci_commit($conn);
echo $where;

}[/codebox]
Thanks in advance for your help.

Sergey Kornilov admin 3/31/2009

Since you use a WHILE loop this will update all records in your database. You only need to run it once. To access key column value use $keys["KeyColumnName"] (replace it with the actual field name).

S
scopley author 4/1/2009

Since you use a WHILE loop this will update all records in your database. You only need to run it once. To access key column value use $keys["KeyColumnName"] (replace it with the actual field name).


When if put in the $keys["columnName"] I get the key values for all the columns, how can I get the $key value for just the record that his selected?
Thanks for all your help. I'm a newbie.

Sergey Kornilov admin 4/1/2009

$keys["KeyColumnName"] is BeforeEdit event holds the value of current record key column.