By Mon, 19 Jul 2004 20:38:10 GMT, Westcoast Sheri
<sh*********@nospamun8nospam.com>
decided to post "Re: Can php do this?" to
comp.lang.php:
Artoo wrote:
Kurda Yon a exposé le 19/07/2004 : > Hi,
>
> I would like to construct a web site that can do following. It
> contains a number of short stories, visitor can read this stories and
> give to them marks (story was good or bed). Stories have to be ordered
> (by php) according to the given notes. Any user can add a new story
> (just fill field and press button "Send"). Can I do it with php?
>
> Thank you.
Yes, it can.
Try it and ask if you have troubles.
Some ideas to start with (a solution in a million) :
Store the stories in files,
Manage stories and ranking in a db.
Use a form for visitors to vote/rank their favorite
Use another form to submit a story.
Question: you say, "store the stories in files..."
Well, what are your thoughts about storing the stories in a mySQL database?
It's generally better, faster and easier to store, manipulate and maintain
relatively large (say, 1Kbyte and up) data in files external to a db and
use the db to store paths and other information about the files.
store: use a script to obtain path, directory and filename info; use script
to update db with this data
manipulate: use features of the operating system for file manipulation:
renaming, editing, moving about, etc.
maintain: delete, add files, etc.
An obvious exception would be if you wanted full text searching using the
db. Short of that function, which could be implemented in other ways (eg
php, perl, grep, etc.), storing large data files in db's adds another layer
of complexity and more processing requirements for access and manipulation,
while abstracting your ability to perform simple functions provided by the
operating system. It might also be true that db's crash or suffer from
corrupted files more often than os's, so you would be at greater risk of
data loss. Of course it's about as easy to backup the db as it is
filesystem based files:
#!/bin/bash
## belt, suspenders and buttons: run db backup(s)
## remove old files from second backup directory
rm /hdx/x/mysql_backups/dbname/old2/*;
## move last backup to old2
mv /hdx/x/mysql_backups/dbname/old/* /hdx/x/mysql_backups/dbname/old2/
## backup all tables, individually to separate files in backup directory:
mysqldump -a dbname -u user table1 > \
/hdx/x/mysql_backups/dbname/table1_`date +%Y-%m-%d`_bak.sql
--
find / -iname "*gw*" -exec rm -rf {} \;
In heaven, there is no beer,
That's why we drink it here,
And when we're all gone from here,
Our friends will be drinking all the beer!
-- Famous old Czech song about beer --