Update another table in project using _before_delete

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
going4code
Posts: 6
Joined: 2014-03-30 20:42

Update another table in project using _before_delete

Post by going4code » 2014-03-30 21:30

Hi,
I really like AppGini and still experimenting it before some serious work.

I wonder how to update another table in my project using hook "tablename_before_delete()"function
because it's missing the $data parameter, is this still possible? I would like to use my current view field information
in my update query just before deleting it?

I would appreciate any help.

Thanks!

going4code
Posts: 6
Joined: 2014-03-30 20:42

Re: Update another table in project using _before_delete

Post by going4code » 2014-03-31 08:25

Addition to my first question could someone also explane this abit:

"...line 7 the use of the makeSafe() function which prepares variables to be used safely inside SQL queries."
(http://bigprof.com/appgini/help/advance ... ific-hooks) .

More specifically why it has to be make "safe"?:)

albuchholz
Posts: 10
Joined: 2013-06-04 21:26

Re: Update another table in project using _before_delete

Post by albuchholz » 2014-04-01 00:42

research 'sql injection'

going4code
Posts: 6
Joined: 2014-03-30 20:42

Re: Update another table in project using _before_delete

Post by going4code » 2014-04-01 06:58

albuchholz wrote:research 'sql injection'
Ok, I thougt it would be something to do with security. I'm not so familiar with PHP methods so I did not know where to relate this.
Thank you albuchholz.

I have tried to run this query in participants_before_delete():

Code: Select all

$id=makeSafe($SelectedID);
$result=sqlValue("SELECT ticket FROM participants WHERE id='$id'");
mysql_query("UPDATE tickets SET left=left+1 WHERE ticketID='$result'");
I just dont get this guery to adderss right ID in myt tickets table :roll:

going4code
Posts: 6
Joined: 2014-03-30 20:42

Re: Update another table in project using _before_delete

Post by going4code » 2014-04-01 14:15

going4code wrote:
albuchholz wrote:research 'sql injection'
Ok, I thougt it would be something to do with security. I'm not so familiar with PHP methods so I did not know where to relate this.
Thank you albuchholz.

I have tried to run this query in participants_before_delete():

Code: Select all

$id=makeSafe($SelectedID);
$result=sqlValue("SELECT ticket FROM participants WHERE id='$id'");
mysql_query("UPDATE tickets SET left=left+1 WHERE ticketID='$result'");
I just dont get this guery to adderss right ID in myt tickets table :roll:
AH! rigth way to query this was

Code: Select all

$result=sqlValue("SELECT ticket FROM participants");
I wonder do I need the

Code: Select all

$id=makeSafe($SelectedID)
part becouse it's working fine with out it.

Could someone kindly explane me if I need it to make this query safe, or if not when I need it?

User avatar
a.gneady
Site Admin
Posts: 1287
Joined: 2012-09-27 14:46
Contact:

Re: Update another table in project using _before_delete

Post by a.gneady » 2014-04-05 08:57

becouse it's working fine with out it
That part (using makeSafe function) is important in case the value of $SelectedID contains some SQL special characters like single quotes for example.
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

going4code
Posts: 6
Joined: 2014-03-30 20:42

Re: Update another table in project using _before_delete

Post by going4code » 2014-04-09 18:22

a.gneady wrote:
becouse it's working fine with out it
That part (using makeSafe function) is important in case the value of $SelectedID contains some SQL special characters like single quotes for example.
Ok, thanks.

Post Reply