jsphp Posted April 9, 2008 Share Posted April 9, 2008 Hi I am have trouble parsing a query, I want to secretly add information to a postgresql query that identifies a user for example create table test (name varchar(500)) becomes : create table test (user_id int, name varchar(500)); I have attempted to do this but the best I got was searching for the opening brackets which gave the result create table test (user_id int, name varchar(user_id int, 500)) I also have the same problem when it comes to inserting if the user enters insert into test values ('000'); that is fine I just have to search for "('" however if the user types in insert into test (column 1, column2) values ('000'); I try to parse the user_id column by identifying "(" but that will find it for both column and value which is not what I want. Ideally I would like to find the nth occurance of a character and a single character followed by text e.g." (" rather than "(' " so it knows which to parse and which no to. Thanks! I would be greatful to anyone who could help Quote Link to comment https://forums.phpfreaks.com/topic/100332-solved-please-help-parsing/ Share on other sites More sharing options...
quiettech Posted April 9, 2008 Share Posted April 9, 2008 This is doable jsphp. But for best results it involves creating one preg_replace for every operation; that is one for INSERT INTO, another for CREATE TABLE, etc. But before we get into the details of that, I'm pretty sure Postgre supports sophisticated logging operations schema wide (not confirmed. Just my guess). This would be a much better approach. What do you think? Quote Link to comment https://forums.phpfreaks.com/topic/100332-solved-please-help-parsing/#findComment-513453 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.