Database alternative

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jaymoore_299
Forum Contributor
Posts: 128
Joined: Wed May 11, 2005 6:40 pm
Contact:

Database alternative

Post by jaymoore_299 »

(First time PHP programmer)

I have used MySQL before, but whenever there are some server problems, any access to the data causes the page to have upwards to 6 seconds before it starts to load. When I took out the line that accessed the database, the page loaded instantly.

I don't really require a very big database, just enough to hold, at maximum, probably a couple paragraph's worth of data. I mainly just want to record daily visitor and traffic out stats in one file, then archive that into a larger file that holds 30 days worth of such data.

Should I just use a text file for this? Any other alternatives?

How do I go about making a secure database file that cannot be accessed by anyone but me?
php_wiz_kid
Forum Contributor
Posts: 181
Joined: Tue Jun 24, 2003 7:33 pm

Post by php_wiz_kid »

Are you storing entire pictures in the database? It shouldn't take long to access text, especially from a MySQL database.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

sounds to me like you had something configured wrong with MySQL. when you ran queries from the command line interface of MySQL, was it still slow?

If I were you, I'd keep trouble shooting that front as MySQL is going to be your best solution big or small.
php_wiz_kid
Forum Contributor
Posts: 181
Joined: Tue Jun 24, 2003 7:33 pm

Post by php_wiz_kid »

If you are storing entire pictures in the database then stop! Instead of storing pictures just store the document path to the folder in the database instead of the actual picture.
jaymoore_299
Forum Contributor
Posts: 128
Joined: Wed May 11, 2005 6:40 pm
Contact:

Post by jaymoore_299 »

No, I'm not storing pictures. I did not configure the MySql myself. I was just having some problems with it in the past, now it seems to work fine, but I was thinking of using a text based database because of those incidents. If there is a way to secure a text based file, then I'd prefer that.
php_wiz_kid
Forum Contributor
Posts: 181
Joined: Tue Jun 24, 2003 7:33 pm

Post by php_wiz_kid »

Some people use XML as a database file. I wouldn't recommend it and I don't know of a way to make it secure since they could look at it if they knew the url to the text/XML file. Maybe you could do something with .htaccess/.htpaswd if you're using Apache. I don't know how though.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

You can achieve some pretty rough and ready results by just using delimitted text files and a small amount a regex (or a large amount of explode() etc). I used to do this in the days before I actually bothered to learn MySQL :P

Code: Select all

#somesection
field1 ::@:: field2 ::@:: field3
field1 ::@:: field2 ::@:: field3
field1 ::@:: field2 ::@:: field3
field1 ::@:: field2 ::@:: field3
#end_somesection

#anothersection
field1 ::@:: field2
field1 ::@:: field2
#end_anothersection
Providing you're comfortable with the filesystem functions fopen() fread(), fwrite() etc and you carefully consider an appropriate delimter to use then for small amounts of data you should be ok.

I actually ran a website with over 3000 ringtones using a system like this as a noob (oh dear :oops: ).
php_wiz_kid
Forum Contributor
Posts: 181
Joined: Tue Jun 24, 2003 7:33 pm

Post by php_wiz_kid »

In college I had to develop VB .NET apps using a comma seperated approach. It was truly a pain. Use MySQL if you can :wink:
Post Reply