function hook_chado_node_sync_select_query

2.x tripal_core.chado_nodes.api.inc hook_chado_node_sync_select_query($query)

Alter the query that retrieves records to be sync'd (optional)

This might be necessary if you need fields from other chado tables to create your node or if your chado node type only supports a subset of a given table (ie: a germplasm node type might only support node creation for cerain types of stock records in which case you would need to filter the results to only those types).

Note: For your own module, replace hook in the function name with the machine-name of your chado node type (ie: chado_feature).

Parameters

$query: An array containing the following: 'select': An array of select clauses 'joins: An array of joins (ie: a single join could be 'LEFT JOIN {chadotable} alias ON base.id=alias.id') 'where_clauses: An array of where clauses which will all be AND'ed together. Use :placeholders for values. 'where_args: An associative array of arguments to be subbed in to the where clause where the

Related topics

2 functions implement hook_chado_node_sync_select_query()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

chado_contact_chado_node_sync_select_query in tripal_contact/includes/tripal_contact.chado_node.inc
Implements [content_type]_chado_node_sync_select_query().
chado_pub_chado_node_sync_select_query in tripal_pub/includes/tripal_pub.chado_node.inc
Implements [content_type]_chado_node_sync_select_query().

File

tripal_core/api/tripal_core.chado_nodes.api.inc, line 1315
API to handle much of the common functionality implemented when creating a drupal node type.

Code

function hook_chado_node_sync_select_query($query) {

  // You can add fields to be selected. Be sure to prefix each field with the
  // tale name.
  $query['select'][] = 'example.myfavfield';

  // Provide any join you may need to the joins array. Be sure to wrap the
  // table name in curly brackets.
  $query['joins'][] = 'LEFT JOIN {exampleprop} PROP ON PROP.example_id=EXAMPLE.example_id';

  // The category should be a unique id for a group of items that will be
  // concatenated together via an SQL 'OR'.  By default the $where_clases
  // variable will come with categories of 'id', 'organism' and 'type'.
  // you can add your own unique category or alter the contents of the existing
  // categories.  Be sure to make sure the category doesn't already exist
  // in the $query['where_clauses']
  $category = 'my_category';

  // Provide any aditionall where clauses and their necessary arguments.
  // Be sure to prefix the field with the table name.   Be sure that the
  // placeholder is unique across all categories (perhaps add a unique
  // prefix/suffix).
  $query['where_clauses'][$category][] = 'example.myfavfield = :favvalue';
  $query['where_args'][$category][':favvalue'] = 'awesome-ness';

  // Must return the updated query
  return $query;
}