English 中文(简体)
A. 界定的用户领域 PHP Mysql
原标题:User Defined Fields PHP Mysql

I am currently building a small crm application. I need each user to be able to define their own custom fields. I am currently building this crm using php and mysql.

例如:我有一个“客户”表,有标准领域:姓名、电话、地址、电子邮件等。 但是,我想允许用户(unique session)在其业务中增加习惯领域,只有他(而不是其他用户)才能进入。 然后,我希望这些习俗领域像表格中所有其他领域一样运作(可检索、发送和收到数据)。 我希望能够在我的奇克勒和php中做到这一点,但愿意接受任何被视为最佳做法的技术或解决办法。 感谢您的帮助。

最佳回答

@Matt H: 这种方法是否被视为“AEV”或仅仅是“标准关系”?

So because i will have many users in many dif industries that will want to add their own custom fields to a number of different tables (contacts, transactions, events, etc) i am assuming that i would need the customfield table to have a user_fk/id or company fk/id, a related table fk/id, an id, and a field name? Am i on the right track? Then in the need to create a 2nd table to hold the data for each custom field buy having a customfield fk/id, customer fk/id, id and a data field to hold the actual data. Is this correct?

因此,一旦在接触表中增加两个表格,我如何增加这些表格,这样,它就象一个大的用户表格,而不是三个表格?

Thanks again for you help.

<>Answer

after much research i have found that most people who wish to accomplish this are using document databases not relational databases.

问题回答

可以通过建立一个称为“海关”的表格,加上“id、外地名称、公司_id”的内容,然后建立一个表格,将这些海关领域与数据联系起来,例如“客户海关数据:id、客户_id”。 同一领域的“所有权”

创造新的习俗领域,“加入习俗领域(外地名称、公司价值)的价值观(出生日、伴侣);”

这是否有助于?

您可以增加储存数据的一栏,并储存介绍习惯细胞内容的阵列。 例如:

$custom = array(
    array("field" => "bikesOwned", "value" => 4),
    array("field" => "travelled", "value" => 14)
);

然后使用PHPs json_encode等东西,在外囚室储存这些数据。 然后,你们都需要做的是编码和处理阵列。

有些人建议使用Entity-Attribute-Value设计,但在此之前,请阅读,介绍一个几乎因无法维护而被毁的EAV设计故事。

更好地解决这一问题,读到。 友好社如何利用MySQL储存无纸数据。 你们可以把所有习俗一栏一分为一栏,以这种方式储存。 然后,如果你想要找到个人特性,就为这一特性建立一个表,该表将数值重新贴在客户表中。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签