Hello everyone, I just started using CakePHP. I followed the blog
tutorial and would like to attach images to posts with David Persson
media plugins, but I wonder if it's possible to use a "many to many"
relation (habtm).
I made this structure in the database:
posts table:
id
title
body
attachments table:
id
model
dirname
basename
checksum
attachments_posts table:
attachment_id
post_id
Models:
class Post extends AppModel {
var $name = 'Post';
var $hasAndBelongsToMany = array(
'Attachment' => array(
'className' => 'Media.Attachment',
'joinTable' => 'attachments_posts',
'foreignKey' => 'post_id',
'associationForeignKey' => 'attachment_id',
)
);
--------------------------------------------------------------------------------------
class Attachment extends AppModel {
var $name = 'Attachment';
var $actsAs = array(
'Media.Transfer' => array(
'trustClient' => false,
'baseDirectory' => MEDIA_TRANSFER,
'destinationFile' =>
':Medium.short::DS::Source.basename:',
'createDirectory' => true
),
'Media.Media' => array(
'metadataLevel' => 2,
'makeVersions' => true,
'filterDirectory' => MEDIA_FILTER
)
);
var $hasAndBelongsToMany = array(
'Post' => array(
'className' => 'Post',
'joinTable' => 'attachments_posts',
'foreignKey' => 'attachment_id',
'associationForeignKey' => 'post_id',
)
);
----------------------------------------------------------------------------------------
This doesn't work: when i add a post it stores the post record in post
table but it doesn't upload the attachment and saves the attachment
record in the database...
Sorry for my English.
Many thanks.
Biusso
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
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