Discussion:
Get the INSERT statement from one row in Mysql
Anton Heuschen
2013-11-05 09:23:35 UTC
Permalink
Good day,

I am trying to find a way, how I can look for one row in a table with a
search for the id, but then I use this to give me the INSERT statement
(which creates this row again)

What I am trying to do, is get an audit where any update - checks the state
of a row, saves it as its INSERT statement and saves this to an audit file
.


Regards

Anton
Camilo Sperberg
2013-11-05 09:40:27 UTC
Permalink
Post by Anton Heuschen
Good day,
I am trying to find a way, how I can look for one row in a table with a
search for the id, but then I use this to give me the INSERT statement
(which creates this row again)
What I am trying to do, is get an audit where any update - checks the state
of a row, saves it as its INSERT statement and saves this to an audit file
.
Regards
Anton
This is more a MySQL related question than a PHP one...

From what I know, there is no way to make MySQL generate an insert statement from an existing row. The only way that I know about would be invoking mysqldump.

If you want an audit log, I suggest you better take a look at the binary logs from MySQL, combining automatic backups+binary log you can easily re-assemble the structure of a table/database. Plus, the binary log has everything you want: it logs dates and times, the exact executed queries and you can easily take snapshots from that.

Greetings.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Camilo "Zabyer" Lozano III
2013-11-18 19:55:28 UTC
Permalink
I suggest create a function & stored procedure for that process...
Post by Camilo Sperberg
Post by Anton Heuschen
Good day,
I am trying to find a way, how I can look for one row in a table with a
search for the id, but then I use this to give me the INSERT statement
(which creates this row again)
What I am trying to do, is get an audit where any update - checks the
state
Post by Anton Heuschen
of a row, saves it as its INSERT statement and saves this to an audit
file
Post by Anton Heuschen
.
Regards
Anton
This is more a MySQL related question than a PHP one...
From what I know, there is no way to make MySQL generate an insert
statement from an existing row. The only way that I know about would be
invoking mysqldump.
If you want an audit log, I suggest you better take a look at the binary
logs from MySQL, combining automatic backups+binary log you can easily
re-assemble the structure of a table/database. Plus, the binary log has
everything you want: it logs dates and times, the exact executed queries
and you can easily take snapshots from that.
Greetings.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
=============================
MetaCatalyst Web Development Team
http://www.metacatalyst.com
http://www.metacatalyst.org

Zabyer Community
http://www.zabyer.org
Bastien
2013-11-18 20:16:59 UTC
Permalink
Thanks,

Bastien
Post by Camilo "Zabyer" Lozano III
I suggest create a function & stored procedure for that process...
Post by Camilo Sperberg
Post by Anton Heuschen
Good day,
I am trying to find a way, how I can look for one row in a table with a
search for the id, but then I use this to give me the INSERT statement
(which creates this row again)
Consider the use of the REPLACE INTO statement which may better handle your situation
Post by Camilo "Zabyer" Lozano III
Post by Camilo Sperberg
Post by Anton Heuschen
What I am trying to do, is get an audit where any update - checks the
state
Post by Anton Heuschen
of a row, saves it as its INSERT statement and saves this to an audit
file
Post by Anton Heuschen
.
Regards
Anton
This is more a MySQL related question than a PHP one...
From what I know, there is no way to make MySQL generate an insert
statement from an existing row. The only way that I know about would be
invoking mysqldump.
If you want an audit log, I suggest you better take a look at the binary
logs from MySQL, combining automatic backups+binary log you can easily
re-assemble the structure of a table/database. Plus, the binary log has
everything you want: it logs dates and times, the exact executed queries
and you can easily take snapshots from that.
Greetings.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
=============================
MetaCatalyst Web Development Team
http://www.metacatalyst.com
http://www.metacatalyst.org
Zabyer Community
http://www.zabyer.org
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Continue reading on narkive:
Loading...