I’ve been scouring the web for a while trying to figure this out. My brain is fried, so I need some help.
I have a model called Containers, a model called Assets and HABTM table called AssetsContainer.
So a container can have many assets…
The first question I have is when I’m doing this operation
$this->Container->read(null,$id);
How do I paginate the assets… right now I am only testing so there’s only 2 assets linked to the container. Am I assuming right that there would be an endless number of assets? If not, still, how do I paginate this data?
Next question is, each asset can be one of three different tables, Photos, Profiles, Blogs. Each of these models has a hasOne relationship of asset_id in each model. How do I get the read() function to retrieve this data automatically? My first instinct is to put a nominal field for each potential table of photo_id, profile_id and blog_id and update the model for Asset with the hasOne of each…. This way it will grab the data right?
Also, is this an instance where instead of read, I use find(‘all’) instead?
Many thanks,
Alan
Example of my Container->read below
Array( [Container] => Array ( [id] => 1 [user_id] => 1 [title] => Default [total_items] => [mime_type] => image [photo_id] => 1 [created] => 2009-12-02 11:53:21 [modified] => 2009-12-02 11:53:21 [is_fan_club] => 0 [fan_club_requirements] => [nsfw] => 0 [ordering] => [active] => [deleted] => ) [User] => Array ( [id] => 1 [user_type_id] => 2 [user_group_id] => 3 [username] => user [email] => [name] => [gender_id] => 1 [password] => [salt] => [birthday] => 1991-11-23 [created] => 2009-11-23 21:41:24 [modified] => 2009-11-24 15:24:59 ) [Photo] => Array ( [id] => 1 [user_id] => 1 [asset_id] => 15 [created] => 1259625133 [modified] => 1259625133 [title] => [deleted] => [file_name] => c0a80aa6-5aab-f111.jpg [rel_path] => users/1/2009/11 [caption] => [server_id] => 1 [is_featured] => ) [Asset] => Array ( [0] => Array ( [id] => 1 [asset_type_id] => [user_id] => [created] => 2009-11-30 16:12:05 [modified] => 2009-11-30 16:12:05 [ordering] => 0 [allow_comments] => 1 [allow_rates] => 1 [nsfw] => 0 [total_views] => 0 [total_rates] => 0 [total_rating] => 0 [total_comments] => 0 [AssetsContainer] => Array ( [id] => 1 [asset_id] => 1 [container_id] => 1 [ordering] => 1 [created] => [modified] => ) ) [1] => Array ( [id] => 2 [asset_type_id] => [user_id] => [created] => 2009-11-30 16:13:47 [modified] => 2009-11-30 16:13:47 [ordering] => 0 [allow_comments] => 1 [allow_rates] => 1 [nsfw] => 0 [total_views] => 0 [total_rates] => 0 [total_rating] => 0 [total_comments] => 0 [AssetsContainer] => Array ( [id] => 2 [asset_id] => 2 [container_id] => 1 [ordering] => 2 [created] => [modified] => ) ) ) )
No comments:
Post a Comment