This topic is locked
[SOLVED]

 Save old data not working.

1/19/2017 5:55:55 PM
PHPRunner General questions
Tandy author

I found the Save old data record in another table.

But I must be doing something wrong.

I have copied the table in mysql so everything is the same. Then I changed the name to that table to trucks_archive and imported the new table into mysql.

I then when to the events page and added:
//** Save old data record in another table ****

// Insert record using Data Access Layer (DAL).

// Another table needs to be part of the project.

global $dal;
$tblEvents = $dal->Table("trucks_archive");

$tblEvents->Value["carrier_id"]=$oldvalues["carrier_id"];

$tblEvents->Value["account_id"]=$oldvalues["account_id"];

$tblEvents->Value["submit_date"]=$oldvalues["submit_date"];

$tblEvents->Value["carrier_name"]=$oldvalues["carrier_name"];

$tblEvents->Value["available_date"]=$oldvalues["available_date"];

$tblEvents->Value["origin_country"]=$oldvalues["origin_country"];

$tblEvents->Value["origin_state"]=$oldvalues["origin_state"];

$tblEvents->Value["origin_city"]=$oldvalues["origin_city"];

$tblEvents->Value["trailer_type"]=$oldvalues["trailer_type"];

$tblEvents->Value["full_partial"]=$oldvalues["full_partial"];

$tblEvents->Value["destination_country"]=$oldvalues["destination_country"];

$tblEvents->Value["destination_state"]=$oldvalues["destination_state"];

$tblEvents->Value["destination_city"]=$oldvalues["destination_city"];

$tblEvents->Add();
I then when off and made a test post and deleted it. It did not copy and insert to trucks_archive table but did delete the post? Is there something I am doing wrong? I have checked all spelling and made sure everything is the same. Is there something else I need to put in?
Thanks for your help.. I am using PHPRunner Enterprise 9.6 (Build 27826 x64)

James

Sergey Kornilov admin 1/19/2017

What event you adding this code to?

Tandy author 1/19/2017



What event you adding this code to?


In my trucks table

Events = List page = Before record deleted

Save old data record in another table
Is that the right place?

lefty 1/19/2017



In my trucks table

Events = List page = Before record deleted

Save old data record in another table
Is that the right place?


I always did it this way below for deleted_values after record deleted.
global $dal;
$tbltrucks_archive = $dal->Table("trucks_archive");

$tbltrucks_archive->Value["carrier_id"]=$deleted_values["carrier_id"];

$tbltrucks_archive->Value["account_id"]=$deleted_values["account_id"];

$tbltrucks_archive->Value["submit_date"]=$deleted_values["submit_date"];

$tbltrucks_archive->Value["carrier_name"]=$deleted_values["carrier_name"];

$tbltrucks_archive->Value["available_date"]=$deleted_values["available_date"];

$tbltrucks_archive->Value["origin_country"]=$deleted_values["origin_country"];

$tbltrucks_archive->Value["origin_state"]=$deleted_values["origin_state"];

$tbltrucks_archive->Value["origin_city"]=$deleted_values["origin_city"];

$tbltrucks_archive_archive->Value["trailer_type"]=$deleted_values["trailer_type"]; //oophs archive listed twice.

$tbltrucks_archive->Value["full_partial"]=$deleted_values["full_partial"];

$tbltrucks_archive->Value["destination_country"]=$deleted_values["destination_country"];

$tbltrucks_archive->Value["destination_state"]=$deleted_values["destination_state"];

$tbltrucks_archive->Value["destination_city"]=$deleted_values["destination_city"];

$tbltrucks_archive->Add();

Tandy author 1/20/2017

Thank you John. That did what I asked to to.. Thank you for your help again.