Php 您想要一个标准语言表作为参考: language ============ id -- autoincrement - or possibly just use code code -- ISO 3-letter code, unique shortCode -- ISO 2-letter code, unique (I think?) name -- ISO standard name
以Php 您想要一个标准语言表作为参考: language ============ id -- autoincrement - or possibly just use code code -- ISO 3-letter code, unique shortCode -- ISO 2-letter code, unique (I think?) name -- ISO standard name,php,sql,Php,Sql,以recordLabel为例: 1) 创建已翻译的表,其中包含需要翻译的所有列: recordLabelTranslation ===================== companyId -- fk to recordLabel.companyId, or whatever the primary key of that table is languageId -- fk to language.id company -- whatever 'companyEn' and 'compa
recordLabel
为例:
1) 创建已翻译的表,其中包含需要翻译的所有列:
recordLabelTranslation
=====================
companyId -- fk to recordLabel.companyId, or whatever the primary key of that table is
languageId -- fk to language.id
company -- whatever 'companyEn' and 'companyKo' was (company name? why translate?)
2) 删除所有已翻译的列(company
,companyKo
)
3) (可选)对视图进行编码,以便于参考。有两种口味:
->语言的简单连接
CREATE VIEW Record_Label_Language as
SELECT recordLabel.companyId, recordLabel.information, -- all current columns...
recordLabelTranslation.languageId, recordLabelTranslation.company
FROM recordLabel
JOIN recordLabelTranslation
ON recordLabelTranslation.companyId = recordLabel.companyid
CREATE VIEW Record_Label_Language_Default as
SELECT recordLabel.companyId, recordLabel.information, -- all current columns...
COALESCE(recordLabelTranslation.languageId, language.languageId),
COALESCE(recordLabelTranslation.company, dflt.company)
FROM recordLabel
JOIN recordLabelTranslation as dflt
ON dflt.companyId = recordLabel.companyid
AND dflt.languageId = [englishLanguageId]
CROSS JOIN language
LEFT JOIN recordLabelTranslation
ON recordLabelTranslation.companyId = recordLabel.companyId
AND recordLabelTranslation.languageId = language.id
->加入语言,默认为英语(或其他语言)
SELECT DISTINCT FROM…
而不是SELECT*FROM…
@EugenRieck是对的,但是你真的应该问一个问题,让我们知道你想要什么。哎呀,我被卷入了解释,忘了添加question@ghoti既然我在尝试从个人和组表循环,那不是只有php吗?我还没有看到任何php看起来像是在结果集循环;问题中唯一真正影响功能(和结果生成)的代码是SQL。正如Eugen所建议的,问题的解决方案几乎肯定是正确构造查询。因此,不,我认为SQL标记是您所需要的,即使您不知道它。:)<代码>选择不同于…而不是选择*来自…
@EugenRieck是对的,但是你真的应该问一个问题,让我们知道你想要什么。哎呀,我被卷入了解释,忘了添加question@ghoti既然我在尝试从个人和组表循环,那不是只有php吗?我还没有看到任何php看起来像是在结果集循环;问题中唯一真正影响功能(和结果生成)的代码是SQL。正如Eugen所建议的,问题的解决方案几乎肯定是正确构造查询。因此,不,我认为SQL标记是您所需要的,即使您不知道它。:)对的En是英语,Ko是韩语。翻译表?那么,一张表是英文的,另一张表是韩文的?我将尝试找到一种方法,将我的个人和团体表合并为一张表。我会听从你的建议。谢谢为什么?个人是一个群体吗(我有点怀疑)?从规范化的设计开始,仅仅因为性能原因(甚至可能不是那样,sorta)才去规范化。个人是为制片人、独唱艺术家等准备的。组是针对组中的个人的。这可能是一个完全不同的后端,但一个选项是它实际上相当于groupId
,并且您可以只拥有一个人的组。正确。En是英语,Ko是韩语。翻译表?那么,一张表是英文的,另一张表是韩文的?我将尝试找到一种方法,将我的个人和团体表合并为一张表。我会听从你的建议。谢谢为什么?个人是一个群体吗(我有点怀疑)?从规范化的设计开始,仅仅因为性能原因(甚至可能不是那样,sorta)才去规范化。个人是为制片人、独唱艺术家等准备的。组是针对组中的个人的。这可能是一个完全不同的后端,但一个选项是它实际上相当于groupId
,并且您可以只拥有一个人的组。
CREATE VIEW Record_Label_Language as
SELECT recordLabel.companyId, recordLabel.information, -- all current columns...
recordLabelTranslation.languageId, recordLabelTranslation.company
FROM recordLabel
JOIN recordLabelTranslation
ON recordLabelTranslation.companyId = recordLabel.companyid
CREATE VIEW Record_Label_Language_Default as
SELECT recordLabel.companyId, recordLabel.information, -- all current columns...
COALESCE(recordLabelTranslation.languageId, language.languageId),
COALESCE(recordLabelTranslation.company, dflt.company)
FROM recordLabel
JOIN recordLabelTranslation as dflt
ON dflt.companyId = recordLabel.companyid
AND dflt.languageId = [englishLanguageId]
CROSS JOIN language
LEFT JOIN recordLabelTranslation
ON recordLabelTranslation.companyId = recordLabel.companyId
AND recordLabelTranslation.languageId = language.id