RE: [PHP] File upload and database optimization questions
| From: | Jason Murray | Date: | Tue, 27 Mar 2001 07:18:23 +0000 |
| Subject: | RE: [PHP] File upload and database optimization questions | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-45702@lists.php.net to get a copy of this message | ||
> 1.
> 2.
Both seem fine to me.
> 3. At the time of upload, it is possible to specify a list of
> users who can "view" and "modify" the file. Currently I am storing
> this list as a whitespace-separated list in a mySQL TEXT column.
>
> Column "view" data: 3 11 1
>
> At the time of displaying the list, I first SELECT * the entire list
> of files, and then use explode() in combination with a "for" loop to
> split up the "view" field and match each element againt the current
> user's ID. Only if a match is found will I display the filename.
>
> I suspect this approach is not optimal. Can anyone suggest a
> better approach?
Rather than a whitespace-separated list, store one ID as a "|ID|". So
your field might look like:
Column "view" data: '|3||11||1|'
That way, knowing the user's ID who is viewing docs, you can select
<<blah blah>> WHERE view LIKE '|$thisusersidnumber|' ... no longer
any need to step through and explode the array.
Jason