Code: Select all
CREATE TRIGGER [dbo].[CreditDetailUpdateTrg]
ON [dbo].[CreditDetail] AFTER UPDATE
AS
INSERT INTO dbo.CreditDetailLog(DetailID, Old_Status, New_Status,Old_InvoiceNumber,New_InvoiceNumber)
SELECT i.DetailID, d.[Status], i.[Status],d.InvoiceNumber,i.InvoiceNumber
FROM Inserted i
LEFT JOIN Deleted d ON i.DetailID = d.DetailID
In the php i have a username in a session so this is available at every point
my question is how do i pass the username into the log table when they do an update to that table.
I should probably mention that the update is done through the php. so this might make it easier.
Could i maybe pass it into the trigger as a parameter.