The way I do this: Tables: - images - videos - documents
Each of the tables has the standard fields like mime_type, filesize, path, etc. And each custom type has any extra fields that may be necessary (width, height, duration, bitrate, etc). Behaviors: - FileBehavior - ImageBehavior extends FileBehavior - VideoBehavior extends FileBehavior The reason I split into multiple tables is for associations. Often I want to control what media types are associated with my models. Eg. I might want a model to have many images but just one video. Plus, this prevents you from having to constantly check the media type if you're iterating through one array with multiple media types. Hope that helps. Cheers, Adam On Nov 8, 3:06 am, Marcus Silva <[EMAIL PROTECTED]> wrote: > Hi folks, > > I am trying to create system which will let users upload media to the > server, the question that I ask is weather using a single table to > store the uploaded files is better than using separate tables to store > each file type in terms of coding. > > Seems to me that if I use the multiple table I will be creating > exactly the same data, but in a different table. > > Example: audios,videos,images etc.... > > My table structure: > > CREATE TABLE `uploaded_files` ( > `id` int(11) unsigned NOT NULL auto_increment, > `foreign_id` int(10) unsigned NOT NULL, > `model` varchar(255) NOT NULL COMMENT 'Associated model name', > `media` varchar(55) NOT NULL, > `filename` varchar(255) default NULL, > `ext` varchar(10) default NULL, > `mime` varchar(55) default NULL, > `filesize` int(11) NOT NULL, > `webpath` varchar(255) NOT NULL COMMENT 'Web path to show file', > `full_path` text NOT NULL COMMENT 'Full path to file_src', > `hasThumb` tinyint(1) unsigned NOT NULL, > `thumbs` text, > `width` int(11) default NULL, > `height` int(11) default NULL, > `description` varchar(155) default NULL, > `created` datetime default NULL, > `updated` datetime default NULL, > PRIMARY KEY (`id`) > ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; > > Basically, I am looking for an easy solution that will reduce the > amount of code I write.... > > Hope some of you guys can help. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
