> Without testing, I can think of some nice PHP functions to accomplish
this
> rather easy. The table where the data is dumped should contain some id
(I
> would use an autoincrement integer id) and a text or blob field (I
would
> also add a timestamp), then You can do something like:
> $result=mysql_query("select * from thetable where id=theid");
> $row=mysql_fetch_array($result);
> $data=implode(",", $row);
> mysql_query("insert into audittable values (someid, '$data')");
>
> The implode function build a string where all the fields from
> the fetched row become comma-separated.
Excellent. I had an idea that PHPH would have the functions to do the
job but this makes my life a lot easier!
>
> Please note that this code doesn't do any error checking and there are
> probably a number of special cases that will not work without
additional
> coding, like fields containing commas and binary data in blobs.
Yeah, I'll watch out for that. There's no binary data to worry about,
though.
> This line would at least surround all fields with single qoutes:
> $data="'" . implode("','", $row) . "'";
My first thoughts were to store the fields as delimited text, ie as you
suggest.
Thanks a lot!
R.
--
Robin Bowes, System Development Manager, Equal Opportunities Commission,
Room 405A, Overseas House, Quay St., Manchester, M3 3HN, UK.
Tel: +44 (0) 161 838 8321 Fax: +44 (0) 161 835 1657
| Thread |
|---|
| • RE: Store whole record in one field of a | Robin Bowes | 6 Jul |