Page 1 of 1

Need to alter data as written to database

Posted: Sun Feb 15, 2009 3:29 pm
by bulgin
I am monitoring apache logs and writing them to MySQL. The field request_URI always contains a forward slash before the actual URI, for example:

/universe.jpg

Which is normal and fine. Except I need to execute some queries against this field and it would be great if the forward slash wasn't there when I do those queries. I can do SUBSTRING(request_uri FROM 2) in the query, but I'd rather just filter out the forward slash before it is written to the database.

Is there some way to do that so that the forward slash never ends up in the field at all?

Thank you.

Re: Need to alter data as written to database

Posted: Sun Feb 15, 2009 3:50 pm
by Mark Baker
bulgin wrote:Is there some way to do that so that the forward slash never ends up in the field at all?
Yes, you do the substr just before the insert when you're writing the records

Re: Need to alter data as written to database

Posted: Sun Feb 15, 2009 9:16 pm
by bulgin
I'm using mod_log_mysql, an Apache 2.0 module that writes logging data directly to a MySQL database.

I'm too much of a newbie to know how this occurs or where to look so that I can use the substring. If I was writing to the database naturally I could use the string, but I'm clueless when it comes to this process... :cry: