⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Question regarding set_relation



Lord_Zeus
  • profile picture
  • Member

Posted 25 January 2015 - 08:17 AM

I can not make related table. I have this situation: have an idea, which is the usual field:
"product" -> "schet" (data like "62/001/001/005") and I want to connect it to another table "card_tk" -> "produkt_cod." Display I need "product" -> "short_name".

 

How can i solv this problem. If im write this in SQL it seems to be like this: 

select `product`.`short_name`
from product, card_tk
where
product.`schet` =  `card_tk`.`product_cod` and
`card_tk`.`kod` = 2; 

it for examlpe...im need to see in "selector" fild `product`.`short_name`, and connection finds most be on product.`schet` = `card_tk`.`product_cod`. In result of opiratin programm most update a table `card_tk`->`product_cod`

 

I'm realy dont know how to do this....

 


Amit Shah
  • profile picture
  • Member

Posted 26 January 2015 - 18:02 PM

well my friend-if this is going to be a complex query - i will suggest you to have it done 2 ways -

1 - change field_type of the field to array ... and dynamically create an array of values u want to present it to user and set it to the field... (much simpler to go with)

2 - Create a model and set out your own custom query

 

Both should surely work for you.

 

Happy GCing :)