【问题标题】:SugarCRM: How To Configure a SQL Key LengthSugarCRM:如何配置 SQL 密钥长度
【发布时间】:2016-02-24 19:57:56
【问题描述】:

我使用向 SugarCRM 中的自定义字段添加索引的官方方式为 "contacts_cstm" 表添加了以下索引:

$dictionary["accounts_cstm"] = array(
    'table' => 'accounts_cstm',
    'fields' => // We can add fields here, we must have at least the `id_c` field
    array(
      0 =>
        array(
          'name' => 'id_c',
          'type' => 'id',
        ),
    ),
    'indices' => // our custom indexes go here
      array(
        0 =>
          array(
            'name' => 'apellidos_nombre',
            'type' => 'index',
            'fields' =>
              array(
                0 => 'apellidos_c',
                1 => 'nombre_c',
              ),
          ),
      ),
);

问题是我需要限制每个字段的密钥长度。在 SQL 中会是这样的:

ALTER TABLE contacts_cstm 
    ADD INDEX apellidos_nombre (apellidos_c (5), nombre_c (5));  

如何在 SugarCRM 中执行此操作?提前感谢您的帮助!

【问题讨论】:

  • 我认为您需要在字段定义中指定长度,添加索引将覆盖正在使用的字段上设置的长度
  • @EuphoriaGrogi 我找不到有关如何在字段定义中指定长度的文档。您有示例或教程吗?

标签: php sql sugarcrm


【解决方案1】:

在我之前的项目中,我添加了一个自定义字段。此代码位于 \custom\Extension\modules\Cases\Ext\Vardefs

$dictionary['Case']['fields']['case_notice_c']= array(
        'name' => 'case_notice_c',
        'vname' => 'LBL_CASE_NOTICE_C',
        'type' => 'varchar',
        'len' => '255'
); 

如您所见,我有一个属性len,它设置了字段的长度。 找到你的模块的vardef定义,然后修复和重建

【讨论】:

  • 我需要定义索引的长度,而不是字段
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-11-11
  • 1970-01-01
  • 2013-07-16
  • 2012-10-20
相关资源
最近更新 更多