Im using a PHP Procedure to run an SQL statement the I need to modify some of the fields in the retrieved data. I don't care if its the data in memory or ifs its in data in a temporary table, I just to modify it using PHP BEFORE calling the report.
Code: Select all
$s = "
SELECT TaxCustomers.*, CONCAT(cust_lastname, ', ', cust_firstname) AS full_name, 9999 as last4SSN FROM TaxCustomers WHERE TaxCustomers.tax_billdate BETWEEN '2020-01-01' AND '2020-03-01';
";
//This will create my unencryption function to modify a couple of fields that are stored as encrypted data int he table but I want to print on my report unencrypted.
include_once(__DIR__ . "/../myunencryptfunction.php");
//This runs the SQL query against my table to retrieve the data I need.
$t = nuRunQuery($s);
//This is where Im trying to change the two SSN fields which calls my unencryption function to do so. I know this works because Im seeing the debug messages show the correct data.
while($r = db_fetch_array($t)){
nuDebug('Encrypted Primary SSN= ' . $r['cust_prissn'].' Spouse SSN= '. $r['cust_secssn']);
$newcustprissn = unencryptssn($r['cust_prissn']);
$newcustsecssn = unencryptssn($r['cust_secssn']);
nuDebug('Encrypted Primary SSN= ' . $newcustprissn.' Spouse SSN= '. $newcustsecssn);
// This is where I assume I'd be able to CHANGE the two fields in the resulting data from my query. and from the db_fetch_array($t) command. THIS DOES NOT WORK.
$r['cust_prissn'] = $newcustprissn;
$r['cust_secssn'] = $newcustsecssn;
}
instead of the original nuRunQuery. HOWEVER, The debug messages and the field assignments do not appear work, my report runs and then displays the original encrypted SSNs. ITs like the while loop doesn't execute. Why?
Am I not using the correct function in my while loop when creating a Temporary table to manipulate the data? What should I be using?
How do I.
1. Write the for loop or while loop to get each record from the temporary table and assign the encrypted cust_SSN field to a variable?
2. Call my unencryptSSN(cust_SSN) function? to unecrypt the SSN and return it to a variable?
3. Write the UPDATE statement to put it back in the temporary table in the last4SSN field?
4. delete this temporary table AFTER the report has run?