Accessing Large Text Fields

Not all fields within a record are available by default. Large text fields are not automatically provided. If the text field is very large (e.g. residues for an entire chromosome) then it could slow delivery of the web page to the user. Therefore, these fields are purposely not included.

To include a large text field you must manually "expand" the object by using the chado_expand_var() function. This function takes the following arguments:

  • The object for the record (e.g. $variables->['node']->feature)
  • The type of expansion to do (e.g. 'field', 'node', or 'table')
  • The name of the field, node or table to expand. If a field, the name must include the table name as well as the field name (e.g. 'features.residues').

The function returns the object, passed as the first argument, but with the requested expansion.

For example, in the feature table the nucleotide or peptide sequences are stored in the residues field. This is a database text field and not automatically included in the record. To get this information we can expand the record in the following way:

$feature  = $variables['node']->feature;
$feature = chado_expand_var($feature, 'field', 'feature.residues');

Using the example code the residues are added to our feature record. We can then access the residues as any other field:

$residues = $feature->residues;