|
Posted by Jerry Stuckle on 12/14/06 20:52
Michael Fesser wrote:
> .oO(Jerry Stuckle)
>
>
>>Sure they are. What happens if you accidentally delete an image from a
>>directory?
>
>
> User error. What if you accidentally issue a DELETE FROM query without a
> WHERE clause?
>
And it can happen. If you issue a DELETE FROM without a WHERE clause,
the data may or may not be deleted. If you have properly set up the
foreign keys with ON DELETE RESTRICT, data will not be deleted. ON
DELETE CASCADE, the data will be deleted. However, in either case, the
database is consistent. Not so if you just delete a file which is still
being referenced in the database.
>
>>What if you have the images on another server and want to
>>restrict access?
>
>
> Can be done without a database.
>
OK, pray tell, how? Assuming you're on a shared host without NFS
capabilities, for instance.
>
>>How about keeping thousands
>>of images in a single directory? Even Linux slows down when the number
>>of images gets big enough.
>
>
> Depends on the filesystem. But anyway, it would make sense to use some
> subdirectories (one for each gallery) instead of just throwing them all
> together.
>
And that requires additional programing to keep track of each of the
subdirectories, where the files are, etc. Or what if you only have one
gallery?
In a database they're all in one place.
>
>> And how about keeping track of names so you
>>don't get duplicates?
>
>
> The same way as you would do in a database: auto-generated IDs (if
> necessary).
>
Again, extra programming. But here you also have to ensure two
concurrent accesses don't generate the same filename. Databases do that
for you.
>
>>They are all real problems.
>
>
> But easy to solve.
>
With additional programming and complications.
>
>>>It will _definitely_ take longer, see below.
>>
>>It doesn't have to.
>
>
> Calling a script and querying a database will always be slower than just
> returning a static file.
>
Not necessarily. Do you have the statistics to prove this? I have.
For instance, if the data is cached in the DB, accessing it through
MySQL can be faster than through the file system. And if the images
reside on a remote system, access will virtually always be faster
through MySQL than through ftp, http, etc. access.
>
>>>For every(!) single non-static image you have to call a PHP script,
>>>which already slows things down:
>>
>>So? If you want to protect your images, you'll have to call your PHP
>>script anyway. No big deal.
>
>
> Question is if the images in a gallery have to be protected (the OP
> didn't mention that) or not.
>
> Micha
Nope. But you brought it up, in your code. So I responded to it.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[Back to original message]
|