[wp-hackers] Filters to alter all SQL calls

Philip Walton philip at philipwalton.com
Fri Jul 8 15:42:38 UTC 2011


And actually, I think that should be "\s" instead of "\\s". Test it out 
to make sure it works for you, as I haven't personally tested it.


On 7/8/11 8:19 AM, Philip Walton wrote:
> How about something like this?
>
> add_filter('query', 'my_query_filter' );
>
> function my_query_filter($query) {
>     if ( preg_match( "/^\\s*(insert|delete|update|replace|alter) /i", 
> $query ) ) {
>         ...
>     } else {
>         ...
>     }
>     return($query);
> }
>
>
>
> On 7/8/11 7:23 AM, Andrew Gray wrote:
>> Are there filter(s) that are far enough up the chain that would allow 
>> me to alter every SQL call on both the read and write.
>>
>> I would like to Find and Replace every query and every write.
>>
>> Is there somewhere that I can do this with two filters, one for read 
>> and one for write.
>>
>> I do not care about performance, I just want to find and replace all 
>> text on both the read and write.
>>
>> thanks,
>>
>> Andrew
>>
>>
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers


More information about the wp-hackers mailing list