function chado_select_record_check_value_type

2.x tripal_core.chado_query.api.inc chado_select_record_check_value_type(&$op, &$value, $type)

Helper Function: check that the value is the correct type.

This function is used by chado_select_record() when building the $where clause array to ensure that any single values are the correct type based on the table definition. Furthermore, it ensures that NULL's are caught changing the operator to 'IS NULL'.

     $op = '=';
     chado_select_record_check_value_type($op, $value, $table_desc['fields'][$field]['type']);

     $where[] = array(
       'field' => $field,
       'op' => $op,
       'data' => $value
     );

Parameters

$op: The operator being used. This is mostly passed in to allow it to be changed if a NULL value is detected.

$value: The value to be checked and adjusted.

$type: The type from the table definition that's used to determine the type of value.

Related topics

1 call to chado_select_record_check_value_type()
chado_select_record in tripal_core/api/tripal_core.chado_query.api.inc
Provides a generic routine for selecting data from a Chado table

File

tripal_core/api/tripal_core.chado_query.api.inc, line 1440
Provides an API for querying of chado including inserting, updating, deleting and selecting from chado.

Code

function chado_select_record_check_value_type(&$op, &$value, $type) {

  if ($value === NULL) {
    $op = 'IS NULL';
  }
  elseif ($type == 'int') {
    $value = (int) $value;
  }

}