1

我真的不確定我會找人幫忙,但讓我們試試吧!ajaxCRUD.com多種關係

我使用的是ajaxCRUD.com的CRUD腳本,我想在我的表格之間創建多個關係。但是,當我嘗試這樣做時,只會出現第一個關係。

我想我fruits表與properties錶鏈接:

$tblDemo = new ajaxCRUD("Fruits", "my_fruits", "id", "../"); 
$tblDemo->defineRelationship("id", "properties", "id", "color"); 
$tblDemo->defineRelationship("id", "properties", "id", "taste"); 

如果我想要得到的顏色,並從相同的「relationshipped」表的味道,只是其中之一將顯示。

有關我如何在同一個表的兩個(或多個)列之間建立關係的任何提示?

回答

0

在我的例子

$tblFriend->defineRelationship("idCliente", "clientes", "idClientes","nombreCliente"); 
$tblFriend->defineRelationship("idCategoria", "categorias", "idCategoria","nombreCategoria"); 

我看到了兩個完美的關係。沒有額外的代碼或任何東西

enter image description here

0

如果你在數據庫中創建一個視圖來連接顏色和味道,是這樣的:

CREATE VIEW v_properties AS 
SELECT id, CONCAT(color, ' - ', taste) AS color_taste 
FROM properties; 

,然後引用這一觀點在你的代碼:

$tblDemo->defineRelationship("id", "v_properties", "id", "color_taste"); 

將這項工作?

或者,如果有意見的工作,創造一種觀點認爲僅僅是屬性的別名:

CREATE VIEW properties2 AS 
SELECT * FROM properties 

,並在你的第二個鏈接使用properties2:

$tblDemo->defineRelationship("id", "properties", "id", "color"); 
$tblDemo->defineRelationship("id", "properties2", "id", "taste");