FuelPHP ORM 可以处理这个数据库设计吗?
我想知道 Fuel ORM 是否可以处理此处描述的设计:
http://www .codeproject.com/KB/aspnet/LocalizedSamplePart2/normalizedSchema.gif
必须生成并执行以下 SQL 或类似的内容:
SELECT CultureId
FROM Culture WHERE CultureName = @CultureName
SELECT I.ItemId, IL.[Name], IL.[Description],
I.Price, CL.[Name], CL.[Description]
FROM Item I
INNER JOIN Item_Locale IL ON I.ItemId = IL.ItemID AND IL.CultureId = @CultureIdD
INNER JOIN Category C ON I.CategoryId = C.CategoryId
INNER JOIN Category_Locale CL ON C.CategoryID = CL.CategoryId AND CL.CultureId = @cultureId
WHERE I.SellerId = @SellerID
或者我必须使用普通查询?
请指教。
I'm wondering if Fuel ORM can handle the design described here:
http://www.codeproject.com/KB/aspnet/LocalizedSamplePart2/normalizedSchema.gif
The following SQL, or maybe something similar, must be generated and executed:
SELECT CultureId
FROM Culture WHERE CultureName = @CultureName
SELECT I.ItemId, IL.[Name], IL.[Description],
I.Price, CL.[Name], CL.[Description]
FROM Item I
INNER JOIN Item_Locale IL ON I.ItemId = IL.ItemID AND IL.CultureId = @CultureIdD
INNER JOIN Category C ON I.CategoryId = C.CategoryId
INNER JOIN Category_Locale CL ON C.CategoryID = CL.CategoryId AND CL.CultureId = @cultureId
WHERE I.SellerId = @SellerID
Or I must use normal queries?
Please advise.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要按照已给出的链接中的描述配置主键和外键 。
从给定关系的示例来看:
的查询看起来像这样:
我假设区域设置在运行时不会更改,但可以不要进行硬编码。在这种情况下,您需要类似以下内容。首先设置默认条件,这些条件始终是关系的一部分。这些需要添加到模型中关系的定义中,如 Model_Item 中的以下示例。
我还无法添加实际的 where 条件,因为它必须是动态的,并且您不能在类属性定义中添加它。因此,我们将在类加载的毫秒添加它:
这将每次添加到连接部分,紧邻主键-外键匹配。
该查询将返回一组项目,这些项目将在属性中包含区域设置信息,并具有一组类别,这些类别都有自己的区域设置属性来描述它们。
You'll need to configure the primary keys and foreign keys as described in the link already given.
Judging by the example given the relations are:
The query for would look something like this:
I am assuming the locales don't change during runtime, but can't be hardcoded. In which case you need something like the following. Start with setting up the default conditions that are always part of the relations. These need to be added to the definition of the relations in the models, like the following example that would be in Model_Item.
I couldn't add the actual where condition yet as it has to be dynamic and you can't have that in a class property definition. Thus we'll add it the millisecond the class is loaded:
This will be added to the join-on part each time, next to the primarykey-foreignkey matching.
The query will return a set of items which will have the locale info inside a property and have an array of categories which all have their own locale property describing them.