Log Search

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
Asawyer13
Posts: 21
Joined: 2016-08-28 22:40

Log Search

Post by Asawyer13 » 2021-05-21 20:33

When the user Searches for data in my list, I want to log the request in a table, along with when the search was done, what was searched for, the IP for the search, and how many records were retrieved.

What's the best way to trap the search event and log this?

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1638
Joined: 2018-04-01 10:12

Re: Log Search

Post by pbottcher » 2021-05-21 21:42

Hi,

I would suggest you use the hooks/TABLENAME.php -> init function. Here you can catch the $_REQUEST array and the $_SERVER to catch most of your data. For the amount for matches you need to run the query with the search once.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

Asawyer13
Posts: 21
Joined: 2016-08-28 22:40

Re: Log Search

Post by Asawyer13 » 2021-05-24 00:04

I don't understand yet how to hook into the Search process to log the results I'm looking for.

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1160
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Log Search

Post by onoehring » 2021-05-25 15:38

Hi,

do as pbötcher suggested: Open the /hooks/tablename.php file in an editor, search for the function tablename_init and use PHP to read the $_REQUEST string.
If it's a search, then isolate the items and formulate the sql request. Once done, use that to retrieve the number of items the search will return (imho not very useful, as this value probably changes over time).
Write all data that you want to log into some logging table. Then simply continue with the "regular" page.

I would suggest, you create a new function for your purpose and simply call that function from within the _init function. This will make handling things in the future much easier for you.

Olaf

Post Reply