Emir Karsiyakali
Emir Karsiyakali

Reputation: 11

Grocery Crud Relation

CREATE TABLE `il` (
  `id` bigint(20) NOT NULL,
  `il_adi` varchar(50) CHARACTER SET utf8 COLLATE utf8_turkish_ci DEFAULT NULL,
  `slug` varchar(50) CHARACTER SET utf8 COLLATE utf8_turkish_ci DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE `ilce` (
  `id` bigint(20) NOT NULL,
  `il_id` bigint(20) DEFAULT NULL,
  `ilce_adi` varchar(50) CHARACTER SET utf8 COLLATE utf8_turkish_ci DEFAULT NULL,
  `slug` varchar(50) CHARACTER SET utf8 COLLATE utf8_turkish_ci DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

I've 2 tables about City - State. ilce.il_id relation with il.id what I mean,

SELECT * FROM il JOIN ilce ON il.id = ilce.il_id 

How can I do this with Grocery Crud relations? How can I change set_relation function?

Upvotes: 1

Views: 1494

Answers (2)

Ravindr Kr
Ravindr Kr

Reputation: 109

You can always create a view with your query, set primary key and use set relation.

Upvotes: 0

jrierab
jrierab

Reputation: 615

I just answered a very similar question. My answer is:

It is not possible to do this directly, as stated in this forum post by the author:

Actually perhaps it seems obvious to grocery CRUD to have joins and customs queries to the table, but it still NOT an available feature at this moment.

His suggestion is to use the set_model function, which allows to perform the desired SELECT/JOIN by extending the grocery_CRUD_Model.

Upvotes: 0

Related Questions