Skip to main content
Topic solved
This topic has been marked as solved and requires no further attention.
Topic: Action after Delete (Read 1327 times) previous topic - next topic

Action after Delete

Hi guys .
I have built a simply app  with a table "Jobs" witch store all jobs details , When i create new row inside this table will create new table in database with table name based on "jobname" and this work like a charm .
But  i can't make working Action after Delete . 
Here is my code in Action After delete :
Code: [Select]
$rec_name = $modeldata['jobname'];
$db ->rawQuery ("DROP TABLE $rec_name");
Any suggestion ? Thanks .

Re: Action after Delete

Reply #1
@faithslitz‍ add this to Action After Delete
Code: [Select]
$db ->rawQuery("DROP TABLE `{$rec_name}`;");
and add this to Action Before Delete
Code: [Select]
//query the database and return a single row
$db->where("id", $rec_id );
$rec_name = $db->getOne("jobs")['jobname'];

and you are good to go.

Re: Action after Delete

Reply #2
Wow, works like a charm Will. Thank ou very much.

Re: Action after Delete

Reply #3
I try to make the same operation on "Edit Page " to prevent errors after rename "jobsname" . but is not the same as "Action After Delete"
Action Before Update
Code: [Select]
//query the database and return a single row
$db->where("id", $rec_id );
$rec_name = $db->getOne("jobs")['jobname'];
Action After Update
Code: [Select]
$db ->rawQuery("ALTER TABLE `{$rec_name}`;");

What i missing ?

Re: Action after Delete

Reply #4
@faithslitz‍ do the following:
Action Before Update
Code: [Select]
//query the database and return a single row
$db->where("id", $rec_id );
$rec_name = $db->getOne("jobs")['jobname'];

Action After Update
Code: [Select]
$rec_name2 = $modeldata['jobname'];
$db ->rawQuery("RENAME TABLE `{$rec_name}` TO `{$rec_name2}`;");




Re: Action after Delete

Reply #5
I don't know why , but wont work . The table in database remain the same , not renaming .

Re: Action after Delete

Reply #6
@faithslitz‍ from my end it's working fine. When you rename the record, the table name is renamed too.
Action Before Update
Code: [Select]
//query the database and return a single row
$db->where("id", $rec_id );
$rec_name = $db->getOne("jobs")['jobname'];
Action After Update
Code: [Select]
$rec_name2 = $modeldata['jobname'];
$db ->rawQuery("ALTER TABLE `{$rec_name}` RENAME TO `{$rec_name2}`;");

If the above doesn't work, I have attached a modified version of the .ppm file you sent to me.

 

Re: Action after Delete

Reply #7
[Solved] With you project it work , with my not work ,maybe because i make changes after this post . I wanna thank you much for your patience .