function tripal_db_get_db

2.x tripal_db.DEPRECATED.inc tripal_db_get_db($select_values)
3.x tripal_db.DEPRECATED.inc tripal_db_get_db($select_values)
1.x tripal_db.api.inc tripal_db_get_db($select_values)

Purpose: To retrieve a chado database object

   $select_values = array(
     'name' => 'SOFP'
   );
   $db_object = tripal_db_get_db($select_values);

The above code selects the SOFP db and returns the following object:

   $db_object = stdClass Object (
     [db_id] => 49
     [name] => SOFP
     [description] =>
     [urlprefix] =>
     [url] =>
   );

Parameters

$select_values: An array meant to uniquely select a given database

Return value

Chado database object

The database is selected using tripal_core_chado select and as such the $select_values array parameter meant to uniquely identify the database to be returned follows the same form as when using tripal_core_chado_select directly.

Example Usage:

Related topics

File

tripal_db/api/tripal_db.api.inc, line 44
Provides an application programming interface (API) to manage references to external databases

Code

function tripal_db_get_db($select_values) {

  $columns = array(
    'db_id',
    'name',
    'description',
    'urlprefix',
    'url'
  );
  $results = tripal_core_chado_select('db', $columns, $select_values);
  if (sizeof($results) == 1) {
    return $results[0];
  }
  elseif (empty($results)) {
    watchdog('tripal_cdb', 
    'tripal_db_get_db: No db matches criteria values:%values', 
    array('%values' => print_r($select_values, TRUE)), 
    WATCHDOG_WARNING
    );
    return FALSE;
  }
  else {
    watchdog('tripal_db', 
    'tripal_db_get_db: 2+ dbs match criteria values:%values', 
    array('%values' => print_r($select_values, TRUE)), 
    WATCHDOG_WARNING
    );
  }

}