[eluser]atw[/eluser]
I'm no expert but I wouldn't hardcode anything I didn't absolutely-definitely-certainly-irrefutably have to.
It would generally be preferable to store only the filename in the DB and create some form of config file which holds the path to that file. At least you then only need to change the path in ONE PLACE rather than for EVERY ENTRY in the whole DB.
If you need category style control over files, add a category storage column or table to the database, then use that to decide which path to use from your config file.
Example config.php
Code:
$file_paths['mp3'] = 'path/to/mp3s/';
$file_paths['img'] = 'path/to/imgs/';
$file_paths['torrent'] = 'path/to/torrents/';
Example controller.php
Code:
if($result['category'] == mp3) {
send_download($file_paths['mp3'] . $result['filename_from_db']);
}
if($result['category'] == img) {
send_download($file_paths['img'] . $result['filename_from_db']);
}
if($result['category'] == torrent) {
send_download($file_paths['torrent'] . $result['filename_from_db']);
}
Disclaimer:
It has taken me 3 months to get to beginner level in CodeIgniter (but I'm reasonable in raw PHP). So I may be talking complete c3ap and that is only pseudo-code, so you could make it MUCH better