php sql information extraction

php sql information extraction

am 10.09.2007 00:05:23 von Dan99

Hello,

I am working on auditing interactions with a pgsql database using
php. So my question is how can i go about obtaining the following
information for by only being provided a pgsql query.

1. table(s) affected
2. column(s) affected
3. action performed on data (ie. update, insert, select, delete)
4. previous data for each row and column effected (if data changed or
deleted)
5. new data for each row and column effected (or existing data if data
is being selected)

Any help with this would be greatly appreciated.

Thanks,
Dan

Re: php sql information extraction

am 10.09.2007 00:15:22 von ivansanchez-alg

Dan99 wrote:

> Hello,
>
> I am working on auditing interactions with a pgsql database using
> php. So my question is how can i go about obtaining the following
> information for by only being provided a pgsql query.

Are you provided the query string, or a resource variable?

--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

Un ordenador no es un televisor ni un microondas, es una herramienta
compleja.

Re: php sql information extraction

am 10.09.2007 00:15:54 von Jerry Stuckle

Dan99 wrote:
> Hello,
>
> I am working on auditing interactions with a pgsql database using
> php. So my question is how can i go about obtaining the following
> information for by only being provided a pgsql query.
>
> 1. table(s) affected
> 2. column(s) affected
> 3. action performed on data (ie. update, insert, select, delete)
> 4. previous data for each row and column effected (if data changed or
> deleted)
> 5. new data for each row and column effected (or existing data if data
> is being selected)
>
> Any help with this would be greatly appreciated.
>
> Thanks,
> Dan
>

If you're presented with the query, you can parse it for the tables and
columns. You can also determine what the action is.

For the rest you would have to query the database itself - there's no
other way to get it in PHP.

Otherwise you need to check in a postgres group to see if that
information is available to you somewhere.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: php sql information extraction

am 10.09.2007 01:03:07 von Dan99

On Sep 9, 6:15 pm, Jerry Stuckle wrote:
> Dan99 wrote:
> > Hello,
>
> > I am working on auditing interactions with a pgsql database using
> > php. So my question is how can i go about obtaining the following
> > information for by only being provided a pgsql query.
>
> > 1. table(s) affected
> > 2. column(s) affected
> > 3. action performed on data (ie. update, insert, select, delete)
> > 4. previous data for each row and column effected (if data changed or
> > deleted)
> > 5. new data for each row and column effected (or existing data if data
> > is being selected)
>
> > Any help with this would be greatly appreciated.
>
> > Thanks,
> > Dan
>
> If you're presented with the query, you can parse it for the tables and
> columns. You can also determine what the action is.
>
> For the rest you would have to query the database itself - there's no
> other way to get it in PHP.
>
> Otherwise you need to check in a postgres group to see if that
> information is available to you somewhere.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================

Yes, I am provided with the actual query (ex. "INSERT INTO table_bob
(column1, column2) VALUES ('value1', 'value2')"). How would I go
about doing the parsing in php?

Re: php sql information extraction

am 10.09.2007 03:22:42 von Jerry Stuckle

Dan99 wrote:
> On Sep 9, 6:15 pm, Jerry Stuckle wrote:
>> Dan99 wrote:
>>> Hello,
>>> I am working on auditing interactions with a pgsql database using
>>> php. So my question is how can i go about obtaining the following
>>> information for by only being provided a pgsql query.
>>> 1. table(s) affected
>>> 2. column(s) affected
>>> 3. action performed on data (ie. update, insert, select, delete)
>>> 4. previous data for each row and column effected (if data changed or
>>> deleted)
>>> 5. new data for each row and column effected (or existing data if data
>>> is being selected)
>>> Any help with this would be greatly appreciated.
>>> Thanks,
>>> Dan
>> If you're presented with the query, you can parse it for the tables and
>> columns. You can also determine what the action is.
>>
>> For the rest you would have to query the database itself - there's no
>> other way to get it in PHP.
>>
>> Otherwise you need to check in a postgres group to see if that
>> information is available to you somewhere.
>>
>> --
>> ==================
>> Remove the "x" from my email address
>> Jerry Stuckle
>> JDS Computer Training Corp.
>> jstuck...@attglobal.net
>> ==================
>
> Yes, I am provided with the actual query (ex. "INSERT INTO table_bob
> (column1, column2) VALUES ('value1', 'value2')"). How would I go
> about doing the parsing in php?
>

Not easy, but you can check out regular expressions. Strcmp will also work.

Maybe check the library or bookstore for books on parsing strings?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: php sql information extraction

am 10.09.2007 10:21:50 von gosha bine

On 10.09.2007 01:03 Dan99 wrote:
> On Sep 9, 6:15 pm, Jerry Stuckle wrote:
>> Dan99 wrote:
>>> Hello,
>>> I am working on auditing interactions with a pgsql database using
>>> php. So my question is how can i go about obtaining the following
>>> information for by only being provided a pgsql query.
>>> 1. table(s) affected
>>> 2. column(s) affected
>>> 3. action performed on data (ie. update, insert, select, delete)
>>> 4. previous data for each row and column effected (if data changed or
>>> deleted)
>>> 5. new data for each row and column effected (or existing data if data
>>> is being selected)
>>> Any help with this would be greatly appreciated.
>>> Thanks,
>>> Dan
>> If you're presented with the query, you can parse it for the tables and
>> columns. You can also determine what the action is.
>>
>> For the rest you would have to query the database itself - there's no
>> other way to get it in PHP.
>>
>> Otherwise you need to check in a postgres group to see if that
>> information is available to you somewhere.
>>
>> --
>> ==================
>> Remove the "x" from my email address
>> Jerry Stuckle
>> JDS Computer Training Corp.
>> jstuck...@attglobal.net
>> ==================
>
> Yes, I am provided with the actual query (ex. "INSERT INTO table_bob
> (column1, column2) VALUES ('value1', 'value2')"). How would I go
> about doing the parsing in php?
>

You can try PDO_User and its parseSQL function

http://pecl.php.net/package/pdo_user


--
gosha bine

makrell ~ http://www.tagarga.com/blok/makrell
php done right ;) http://code.google.com/p/pihipi