Page 1 of 1

Update another table in project using _before_delete

Posted: 2014-03-30 21:30
by going4code
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!

Re: Update another table in project using _before_delete

Posted: 2014-03-31 08:25
by going4code
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"?:)

Re: Update another table in project using _before_delete

Posted: 2014-04-01 00:42
by albuchholz
research 'sql injection'

Re: Update another table in project using _before_delete

Posted: 2014-04-01 06:58
by going4code
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:

Re: Update another table in project using _before_delete

Posted: 2014-04-01 14:15
by going4code
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?

Re: Update another table in project using _before_delete

Posted: 2014-04-05 08:57
by a.gneady
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.

Re: Update another table in project using _before_delete

Posted: 2014-04-09 18:22
by going4code
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.