1

我真的不确定我会找人帮忙,但让我们试一试吧!

我正在使用来自 ajaxCRUD.com 的 CRUD 脚本,并且我想在我的表之间创建多个关系。但是,当我尝试这样做时,只会出现第一个关系。

我想将我fruits的表与properties表链接:

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

如果我想从同一个“关系”表中获取颜色和味道,则只有其中一个会显示。

关于我如何在同一张表的两个(或更多)列之间建立关系的任何提示?

4

2 回答 2

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");
于 2013-05-25T14:15:59.700 回答
0

在我的例子中

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

我看到两人的关系很完美。没有额外的代码或任何东西

在此处输入图像描述

于 2014-04-21T14:29:42.230 回答