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");