Good Morning All,
I have a general question that I'm sure someone has an opinion on...
I have several little snippets of code that will be used in various places in my programs operation and to ensure that they are identical in their operation wherever they are used from, I have made each of them a seperate little script and am including them when needed...
My question is This:
Would it be more efficient to make each of them a function and call the function with the required variables, or to do it the way that I am, with a list of Includes to bring in each one in the order that they are needed?
Here is what one of them looks like:
<?php // use include "all_inc/inc_update_mem.php";
// vars required for prod_id 6 - $payor - to update mem_status to D
// and increase existing subs_internal payment by $amount
if ($prod_id == '6'){// IR Upgrade - Must be a Customer
$sql = "
UPDATE members
SET mem_status='D', last_update='".$created."'
WHERE mem_id = '".$payor."'
LIMIT 1
";
mysql_query($sql);
$sql = "
UPDATE subs_internal
SET next_pmt_amt=next_pmt_amt+$amount, last_update='".$created."'
WHERE mem_id = '".$payor."'
LIMIT 1
";
mysql_query($sql);
}else{
// vars required $up1_id/$new_mem_status/$mstr_gen/$created/$payor/$prod_id
// query to update the members record with new data
$sql = "
UPDATE members
SET up1_id='".$up1_id."', mem_status='".$new_mem_status."', mstr_gen='".$mstr_gen."', last_update='".$created."'
WHERE mem_id = '".$payor."'
LIMIT 1
";
mysql_query($sql);
// This should only be done if NOT PTL purchase
if ($prod_id=='1' || $prod_id=='3'){ // set plan to single
$sql = "UPDATE members SET plan='S' WHERE mem_id = '".$payor."' LIMIT 1";
mysql_query($sql);
}elseif ($prod_id=='2' || $prod_id=='4'){ // set plan to Family
$sql = "UPDATE members SET plan='F' WHERE mem_id = '".$payor."' LIMIT 1";
mysql_query($sql);
}
}
?>
I have about a dozen like this (most only about 6-8 lines)
and this is how I utilize them now...
// Get up1_id - 1st avail pos under referrer
// returns $up1_id and $mstr_gen of new position
// ??? which prod_ids does this apply to ?
include "all_inc/inc_get_up_one.php"; // ????
// update members record up1/status/mstr_gen/plan/last_update
include "all_inc/inc_update_mem.php"; // 1-4 and 6
//UPDATE account_track increase ytd_purch and decrease cur_bal
include "all_inc/inc_track_purch.php";// ALL
// Payment for product from members eWallet ?? IR pmt too???
// returns $eW_trans_id
include "all_inc/inc_trans_pmt.php"; // 1-4 and
Would it be more efficient to do them as functions?
Thanks for your response.
Douglas