Hi, Ben.
Really quick question:
I have migrated across from 1.5 > 2.05 and am finishing off updating a substantial chunk of my prior PayPal integration scripts. Naturally, I thought I'd make some improvements along the way but I need some clarification as on how to proceed or if I'm missing anything in particular.
IPN processor works; I've written further code to automate database entries upon verification but I need some help. The following chunk of code checks to see if any of the dedicated paypal fields I've declared are present in the corresponding form table; if not, create them:
Works great!
But I need these newly created fields (or columns) and their corresponding entries to appear from within formtools. Am I correct in assuming that I need to update the ft_form_fields table to reflect this update(?). If so, is there anything else I need to consider, update or be wary of?
Any assistance you'd be willing to provide would be hugely appreciated, Ben.
Really quick question:
I have migrated across from 1.5 > 2.05 and am finishing off updating a substantial chunk of my prior PayPal integration scripts. Naturally, I thought I'd make some improvements along the way but I need some clarification as on how to proceed or if I'm missing anything in particular.
IPN processor works; I've written further code to automate database entries upon verification but I need some help. The following chunk of code checks to see if any of the dedicated paypal fields I've declared are present in the corresponding form table; if not, create them:
PHP Code:
// PayPal IPN Verified
//
//some code
// boom! check if paypal fields exist in table
$query = ("SELECT mc_gross,mc_fee ".
"FROM ".$g_table_prefix."form_".$form_id." ".
"WHERE submission_id='".$submission_id."'");
$result = mysql_query($query)
or die("select from table ".$g_table_prefix."form_".$form_id." not successful: ".
mysql_error());
if(!$result)
{
// create missing fields
$columns = array(
'mc_gross' => "varchar(20)",
'mc_fee' => "varchar(20)"
);
foreach($columns as $key => $value)
{
// checks if any field(s) already exist in table
$query = ("SHOW COLUMNS ".
"FROM ".$g_table_prefix."form_".$form_id." ".
"LIKE '".$key."'");
$result = mysql_query($query)
or die("show columns from table ".$g_table_prefix."form_".$form_id." failed: ".
mysql_error());
$col = mysql_fetch_array($result);
if(NULL == $col[0])
{
// create new field(s) and specify datatype and position in table
$query = ("ALTER TABLE ".$g_table_prefix."form_".$form_id." ".
"ADD COLUMN ".$key." ".$value." ".
"AFTER is_finalized;");
$result = mysql_query($query)
or die("altering table ".$g_table_prefix."form_".$form_id." add column failed: ".
mysql_error());
// update ft_form_fields table
//
//
//
//
}
}
}
//more code
Works great!
But I need these newly created fields (or columns) and their corresponding entries to appear from within formtools. Am I correct in assuming that I need to update the ft_form_fields table to reflect this update(?). If so, is there anything else I need to consider, update or be wary of?
Any assistance you'd be willing to provide would be hugely appreciated, Ben.