Welcome, Guest
Username: Password: Remember me

TOPIC: [SOLVED] How to make one to many relation in brick

[SOLVED] How to make one to many relation in brick 12 Oct 2011 19:26 #214

  • axoloth
  • axoloth's Avatar
  • Offline
  • New Member
  • Posts: 3
  • Karma: 0
Hello,

First, thanks for this fantastic tool !

Here what i want to do :

I create two tables : product [ id, label] and picture[ id, pathToFile, product_id]

I well understand how to link my picture table to the product. I made a form to create picture and i can choose the associated product by a dropdown.

But that's not really what i would : i would prefered have the possibility to create several pictures directly in the product form.

Is it possible ?
Last Edit: 14 Oct 2011 16:11 by admin.
The administrator has disabled public write access.

Re: How to make one to many relation in the form brick 13 Oct 2011 02:32 #215

  • deenison
  • deenison's Avatar
  • Offline
  • New Member
  • Posts: 2
  • Karma: 0
Hi axoloth. It is indeed a fantastic tool!

Well, I think you may have to create an associative table to do what you need here. Would be something like: product( product_id , label ), picture( picture_id , pathToFile ) and, the associative table, product_pictures( picture_id , product_id ). In that way we would be able to associate 'n' pictures to any product.

But I'm also trying to figure out how to "manage" that kind of relationship in the form brick,sry :dry:
The administrator has disabled public write access.

Re: How to make one to many relation in the form brick 13 Oct 2011 05:59 #216

  • axoloth
  • axoloth's Avatar
  • Offline
  • New Member
  • Posts: 3
  • Karma: 0
Good morning,

Sorry for my poor english, i think i didn't well expose my problem.

Deenison, that's not a database relations' problem. Having a product_picture will only permit to re-use a photo for others products. Having a foreign key in product_id in picture is suffisant to join n pictures to one product ;) .

My problem, is how can i do in Cook to iterate the creation of my pictures, in the same view as the product's one.
Last Edit: 13 Oct 2011 06:01 by axoloth.
The administrator has disabled public write access.

Re: How to make one to many relation in the form brick 13 Oct 2011 16:45 #219

  • admin
  • admin's Avatar
  • Online
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
No, I facts, it is not possible for the moment.

You must write by yourself this functionality.


Look how Cook is dealing with Models...

Fiew lines in the view file :
$modelPictures =& JModel::getInstance('Pictures', 'XxxxsModel');
$modelPictures->addWhere("a.product = " . (int)$MyproductID);
$pictures = $modelPictures->getData();


Hope this will help you
Coding is now a piece of cake
Last Edit: 13 Oct 2011 16:46 by admin.
The administrator has disabled public write access.

Re: How to make one to many relation in the form brick 14 Oct 2011 06:19 #237

  • axoloth
  • axoloth's Avatar
  • Offline
  • New Member
  • Posts: 3
  • Karma: 0
Yes, that's what i supposed regarding the code.

Maybe it's an interresting add for futurs versions of Cook...

I will write this by the hand.

Thanks for replies.
The administrator has disabled public write access.
Time to create page: 0.082 seconds

Get Started