简体   繁体   中英

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?

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.

您始终可以使用查询创建视图,设置主键并使用设置关系。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM