This topic is locked

AfterAdd() Help

3/26/2007 11:31:25 PM
PHPRunner General questions
E
evan_ad2000 author

Hi,
I am having problems with an AfterAdd() which I wrote:
function AfterAdd(&$values)

{

//** Insert a record into another table ****

global $conn;

$strSQLInsert = "insert into itemtransaction (date, transaction_id, customer_id) values ('".date('g:i:sA 1 j/m/Y')."',

'".$values['transaction_id']."', '".$values['customer_id']."')";

db_exec($strSQLInsert,$conn);
}
inside the php file that runs this function, I added the parameter like this:
AfterAdd($avalues);
This actually works and adds something into the table itemtransaction but everything is empty. Why is this so? The structure of itemtransaction looks like this:
item_id(INT)

date

transaction_id

customer_id

supplier_id
item_id is suppose to be auto-incremented, how can I do this? like evertime I try to add something, it will add one to the last entry.

Sergey Kornilov admin 3/27/2007

AfterAdd function don't have any parameters.
Use BeforeAdd function for ths purpose.

W
weber 3/28/2007

AfterAdd function don't have any parameters.

Use BeforeAdd function for ths purpose.


It would be extremely helpfull if it was possible to use the AfterAdd function in the same manner as the BeforeAdd function
A small explanation, when I add a new row to my DB I send an e-mail with an attached file to a mail recipient his e-mail is in the DB. I found out that I had to use BeforeAdd to access the values in the DB.

The problem is that one of the fields in my DB is unique so when I tried to add the same value for this field once more the e-mail was send with the wrong data and I was correctly told that this was a duplicate entry so nothing was added to the DB.
So please change the afteradd function to work the same way as the beforeadd.

Regards

Steen