Need to alter data as written to database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bulgin
Forum Commoner
Posts: 29
Joined: Wed Feb 11, 2009 8:47 pm

Need to alter data as written to database

Post 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.
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: Need to alter data as written to database

Post 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
bulgin
Forum Commoner
Posts: 29
Joined: Wed Feb 11, 2009 8:47 pm

Re: Need to alter data as written to database

Post 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:
Post Reply