List:General Discussion« Previous MessageNext Message »
From:Robin Bowes Date:July 6 1999 9:48am
Subject:RE: Store whole record in one field of a
View as plain text  
> Without testing, I can think of some nice PHP functions to accomplish   
> rather easy. The table where the data is dumped should contain some id   
> would use an autoincrement integer id) and a text or blob field (I   
> 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   
> 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,   

> 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   

Thanks a lot!

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
RE: Store whole record in one field of aRobin Bowes6 Jul