This topic is locked

Check to see if column exists in the table being edited

7/26/2022 2:38:32 PM
PHPRunner General questions
A
asawyer13 authorDevClub member

I want to add code for updating a couple columns like date modified.
I would like to add the code to all my before update events, even if the table doesn't currently have a date modified column in it.
That was if I eventually add a date modified column it will automatically work.

Is there a way to check to see if a column exists in my table during before add and before update events?

Thanks
Alan

Sergey Kornilov admin 7/26/2022

It will be cumbersome but check this post on Stackoverflow for instance.

A
asawyer13 authorDevClub member 7/27/2022

I was thinking I might be able to interogate the data values somehow like $data["datamodified"] == nil or something.

But if it can't be done, I don't think it's worth doing a database query so I'll just only put the code in if the column(s) exist.

Alan