Jump to content


N to N Relation

set_relation set_relation_n_n

  • Please log in to reply
7 replies to this topic

#1 RSPeres

RSPeres

    Member

  • Members
  • PipPip
  • 12 posts

Posted 16 January 2013 - 01:57 PM

Hi,

Is it possible to use this kind of query using set_relation_n_n? And populate the combos??



SELECT
c.cidade_id, c.cidade_nome, r.regiao_id, r.regiao_nome, e.estado_id, e.estado_sigla
FROM
tbl_area_atuacao a
INNER JOIN
tbl_cidades c
ON
c.cidade_id = a.cidade_id
INNER join
tbl_estados e
on
e.estado_id = c.estado_id
inner join
tbl_regioes r
on
r.regiao_id = e.regiao_id
where
a.atuacao_id = 1

The combo sequence will be tbl_regioes->tbl_estados->tbl_cidades

Thank's in advance

Attached Thumbnails

  • Screen Shot 2013-01-16 at 11.57.17 AM.png


#2 goFrendiAsgard

goFrendiAsgard

    Advanced Member

  • Members
  • PipPipPip
  • 137 posts

Posted 20 January 2013 - 03:48 PM

I've once do something similar by using MySQL function.
I use the function name as

$crud->set_relation('field_name', 'relation_table_name', 
'{mysql_function(one_of_relation_field_name)}');
I hope it will also work for set_relation_n_n

No-CMS homepage : http://www.getnocms.com
No-CMS forum : http://www.getnocms.com/forum
No-CMS Github page : https://github.com/g...diAsgard/No-CMS

 

Please don't mix up No-CMS and groceryCRUD issues.
(eg: user authentication etc is No-CMS specific issue and has nothing to do with groceryCRUD)

 


#3 Pascal

Pascal

    Newbie

  • Members
  • Pip
  • 7 posts

Posted 22 February 2013 - 09:42 PM

I've once do something similar by using MySQL function.
I use the function name as
 

$crud->set_relation('field_name', 'relation_table_name', 
'{mysql_function(one_of_relation_field_name)}');
I hope it will also work for set_relation_n_n

Which mysql function???



#4 Pascal

Pascal

    Newbie

  • Members
  • Pip
  • 7 posts

Posted 22 February 2013 - 09:43 PM

Hi,

Is it possible to use this kind of query using set_relation_n_n? And populate the combos??

 


SELECT
c.cidade_id, c.cidade_nome, r.regiao_id, r.regiao_nome, e.estado_id, e.estado_sigla
FROM
tbl_area_atuacao a
INNER JOIN
tbl_cidades c
ON
c.cidade_id = a.cidade_id
INNER join
tbl_estados e
on
e.estado_id = c.estado_id
inner join
tbl_regioes r
on
r.regiao_id = e.regiao_id
where
a.atuacao_id = 1

The combo sequence will be tbl_regioes->tbl_estados->tbl_cidades

Thank's in advance

Hi did you find an answer to that problem?



#5 goFrendiAsgard

goFrendiAsgard

    Advanced Member

  • Members
  • PipPipPip
  • 137 posts

Posted 23 February 2013 - 01:23 AM

Which mysql function???

My own custom function.
Something like CREATE FUNCTION function_name


No-CMS homepage : http://www.getnocms.com
No-CMS forum : http://www.getnocms.com/forum
No-CMS Github page : https://github.com/g...diAsgard/No-CMS

 

Please don't mix up No-CMS and groceryCRUD issues.
(eg: user authentication etc is No-CMS specific issue and has nothing to do with groceryCRUD)

 


#6 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 23 February 2013 - 09:20 AM

At difficult cases I don't use the set_relation functions at all. I prefer to use my own model (via set_model) and then use the field_type to pass the values I want to the field!


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#7 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 23 February 2013 - 09:22 AM

My own custom function.
Something like CREATE FUNCTION function_name

 

Good idea but if I need to change it? I would need every time to go back to MySQL or end up with different MySQL functions that are not that easy to maintain.

So I prefer to program my own model and apply from there any level of complexity is needed to my data handling!


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#8 goFrendiAsgard

goFrendiAsgard

    Advanced Member

  • Members
  • PipPipPip
  • 137 posts

Posted 23 February 2013 - 06:16 PM

Good idea but if I need to change it? I would need every time to go back to MySQL or end up with different MySQL functions that are not that easy to maintain.

So I prefer to program my own model and apply from there any level of complexity is needed to my data handling!

Using model is actually better and easier to manage.


No-CMS homepage : http://www.getnocms.com
No-CMS forum : http://www.getnocms.com/forum
No-CMS Github page : https://github.com/g...diAsgard/No-CMS

 

Please don't mix up No-CMS and groceryCRUD issues.
(eg: user authentication etc is No-CMS specific issue and has nothing to do with groceryCRUD)

 






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users