AnsweredAssumed Answered

How can I configure the key length to use for an index?

Question asked by tgirardi on Feb 23, 2016

I have added the following index for the "contacts_cstm" tables:

 

$dictionary["accounts_cstm"] = array(
  'table' => 'accounts_cstm',
  'fields' => //We can added fields here, we must at least have 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',
              ),
          ),
      ),
);

 

The problem is that I need to restrict the key length for each field. In SQL it would be something like this:

 

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

 

How can I do that?

 

Thanks in advance for any help!

Outcomes