Opps.
$belongsTo = array('Zdjecia' => array('className' =>
'Zdjecie',
'foreignKey' => 'zdjecie_id'
of course
On 15 , 13:15, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> You need to change hasOne association in Produkt to belongsTo one.
>
> class Produkt extends AppModel
> {
> var $name = 'Produkt';
> var $belongsTo = array('Zdjecia' =>
> array('className' =>
> 'Zdjecie',
> 'foreignKey' => 'zd_id'
> ))
>
> Don't forget to set $primaryKey='zd_id' in Zdjecie model.
>
> Product belongs to Photo... Hmmm :) but it should work.
>
> rennis:
>
> > Hello,
> > I am a newbie to Cake. I am developing my first app.
> > Sorry for my badly english.
>
> > I have problem with config my Model. I don't now why / 'foreignKey' =>
> > 'zdjecie_id' / not working.
>
> > Zdjecie = ang. Photo
> > Produkt = ang. Product
>
> > I want keep some photos in my table /Zdjecia/. This photos maybe use
> > into another association.
> > For example:
> > Photo PHOTO1 is use for Products PRODUCT_1, PRODUCT_2 and Categorie
> > CATEGORIE_1.
>
> > class Zdjecie extends AppModel
> > {
> > var $name = 'Zdjecie';
> > var $hasMany = array('Produkty' =>
> > array('className' =>
> > 'Produkt',
> > 'conditions' =>
> > '',
> > 'order' => '',
> > 'dependent' =>
> > true,
> > 'foreignKey' =>
> > 'zdjecie_id'
> > )
> > );
> > }
>
> > class Produkt extends AppModel
> > {
> > var $name = 'Produkt';
> > var $hasOne = array('Zdjecia' =>
> > array('className' =>
> > 'Zdjecie',
> > 'conditions' =>
> > '',
> > 'order' => '',
> > 'dependent' =>
> > true,
> > 'foreignKey' =>
> > 'zd_id'
> > )
> > }
>
> > CREATE TABLE `produkty` (
> > `id` int(11) NOT NULL auto_increment,
> > `kategorie_id` int(11) NOT NULL,
> > `products_name` varchar(12) NOT NULL,
> > `products_date_added` datetime NOT NULL,
> > `products_last_modified` datetime default NULL,
> > `zdjecie_id` int(10) unsigned default NULL,
> > PRIMARY KEY (`id`),
> > ) ENGINE=MyISAM
>
> > CREATE TABLE `zdjecia` (
> > `zd_id` int(10) unsigned NOT NULL auto_increment,
> > `file_title` varchar(50) NULL,
> > `file_type` char(4) NOT NULL,
> > `file_name` varchar(20) NOT NULL,
> > PRIMARY KEY (`zd_id`)
> > ) ENGINE=MyISAM
>
> > --- cut debug SQL ---
> > SELECT `Produkt`.`id`, `Produkt`.`kategorie_id`,
> > `Produkt`.`products_name`, `Produkt`.`products_date_added`,
> > `Produkt`.`products_last_modified`, `Produkt`.`zdjecie_id`,
> > `Zdjecia`.`zd_id`, `Zdjecia`.`file_title`, `Zdjecia`.`file_type`,
> > `Zdjecia`.`file_name` FROM `produkty` AS `Produkt` LEFT JOIN `zdjecia`
> > AS `Zdjecia` ON (`Zdjecia`.`zd_id` = `Produkt`.`id`) WHERE
> > kategorie_id = 4
> > --- end cut ---
>
> > I need change / ON (`Zdjecia`.`zd_id` = `Produkt`.`id`) / on to / ON
> > (`Zdjecia`.`zd_id` = `Produkt`.`zdjecie_id`) /
>
> > Could you give mi some advice?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---