Datasheet hasMany DatasheetLine / DatasheetLine belongsTo Datasheet
DatasheetLine belongsTo Ingredient
datasheets
---------------
id
product
more...
datasheet_lines
---------------------
id
datasheet_id
ingredient_id
proportion
twa
stel
ingredients
----------------
id
name
cas
HTH,
- Dardo Sordi.
On Mon, Nov 3, 2008 at 6:41 AM, modfather <michaelm@comcen.com.au> wrote:
>
> Is it possible???
>
> i know questions relating to this are posted ad infinitum on this
> forum - i have searched high and low, far and wide but i have hit the
> "proverbial" - i am going to post this and walk away for a while, and
> in the meantime some generous soul might shed some light....here
> goes.........
>
> I have product datasheets which consist of tables such as the
> following;
>
> Ingredients CAS No Proportion TWA mg/m3 STEL mg/m3
> Amoxycillin 61336-70-7 30-60% not set not set
> hazardous NA to 100% NA NA
>
> Each product is composed of 1 or more ingredients - each ingredient
> can belong to one or more products.
>
> Presently i have a;
> 1. Datasheet model/table
> 2. Ingredient model/table (includes a cas no. field)
> 3. Proportion model/table
> 4. TWA model/table
> 5. STEL model/table
>
> I have also defined a habtm between ingredients and datasheets
> ( datasheets_ingredients).
> table:
> id | datasheet_id | ingredient_id
> 1 5 89
>
> i also need to link the other three models in a habtm relation with
> datasheets_ingredients because each field (proportion,twa,stel) are
> dependent on the combined fields of datasheet_id and ingredients_id.
> For clarity, i cannot select a "proportion" field until i know both
> the datasheet id and the ingredient id - i cannot select the
> proportion field(or twa ,stel) with one or the other it must be both
> fields.
>
> I have attempted multiple habtm tables ie using the above as an
> example
>
> table: datasheet_ingredient_proportion
> id | datasheet_ingredient_id | proportion_id
> 1 1 6
>
> this did not work.
>
> I tried a habtm datasheets_ingredients tabel and also included foreign
> key fields;
>
> using the datasheets_ingredients model and adding a belongsTo
> association with the three models and including a hasMany association
> in their models - to no avail
>
> table:
> id | datasheet_id | ingredient_id | proportion_id | twa_id | stel_id
> 1 5 89
> 12 8 3
>
>
> I have also read numerous other posts which have proved useful but i
> cannot seem to crack it - i can get the result i need with handwritten
> sql - but i would rather attack it using cakes process.
>
> http://groups.google.com/group/cake-php/browse_thread/thread/8870566a07bf499/9f453850323ae695?lnk=gst&q=HABTM+%2B+%22multiple%22#9f453850323ae695
>
> http://debuggable.com/posts/modeling-relationships-in-cakephp-faking-rails-throughassociation:480f4dd6-b990-485e-abe4-4baccbdd56cb
>
> http://www.cricava.com/blogs/index.php?blog=6&title=modelizing_habtm_join_tables_in_cakephp_&more=1&c=1&tb=1&pb=1
>
> http://groups.google.com/group/cake-php/browse_thread/thread/7201009ad57b8263/1de876ae4eb416a8?lnk=gst&q=%22habtm%22+%2B+%22belongsto#1de876ae4eb416a8
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment