On Sun, Feb 13, 2000 at 12:08:34AM -0800, Ed Lazor wrote:
: Has anyone done this?  (or is this considered a bad thing?)

Done it before, would probably do it again.  Not a bad thing at all,
at least from the standpoint of maintaining the site.  You don't have to
deal with lots of files.  Particularly useful when you've got a site with
several hundred pages.

: If you have, could you give me some pointers on the design you used to store
: and retrieve multi-page web documents using the database?

I assume you mean in a style similar to what salon.com and webmonkey.com
do.

: I've been able to store single page web files with no problem.  I'm
: designing something for multi-paged documents and would like to find out
: what approaches
: others have used before I try to reinvent the wheel ;)

Simple..  Two tables something like this (MySQL specific):

create table docs (
        docid int(4) unsigned default '0' not null auto_increment,
        doctitle varchar(255) not null,
        synopsis blob not null
        primary key (docid)
);

create table pages (
        pageid int(4) unsigned default '0' not null auto_increment,
        docid int(4) unsigned not null,
        pagetitle varchar(255) not null,
        seq int(4) unsigned not null,
        pagetext blob not null,
        primary key (pageid)
);

The one-many relationship between docs.docid and pages.docid should be
evident, and tell you all you need..

Make sure you addslashes() before inserting into the blob fields, and 
stripslashes() when pulling back out of blobs.

Here's a sample SQL statement that will grab page 3 of document number 17.

SELECT 
        d.doctitle, p.pagetitle, p.pagetext 
FROM
        pages p, docs d 
WHERE
        d.docid = 17 AND d.docid = p.docid AND p.pageid = 3;

-- 
                 Jason Costomiris <><
            Technologist, cryptogeek, human.
jcostom {at} jasons {dot} org  |  http://www.jasons.org/


-- 
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.

Reply via email to