function drush_salesforce_api_soql_describe in Salesforce Suite 7.2
Same name and namespace in other branches
- 6.2 salesforce_api/salesforce_api.drush.inc \drush_salesforce_api_soql_describe()
Examine a salesforce table. Allows for deep inspection using dot syntax similar to sql databases.
For example to see fields on contact: 'contact.fields' To examine the first field on a contact 'contact.fields.1'
File
- salesforce_api/
salesforce_api.drush.inc, line 82 - Drush integration for Salesforce. Provides commands to examine and query Salesforce data.
Code
function drush_salesforce_api_soql_describe() {
_salesforce_api_drush_check_soap();
$tables = func_get_args();
if ($sf = salesforce_api_connect()) {
foreach ($tables as $t) {
$info = explode('.', $t);
try {
$table = array_shift($info);
$response = salesforce_api_describeSObject($table);
if (!empty($info)) {
$i = array_shift($info);
while (isset($i)) {
if (is_array($response)) {
$response = $response[$i];
}
else {
$response = $response->{$i};
}
$_i = $i;
// Save the last $i value for later.
$i = array_shift($info);
}
}
// If fields were requested give them some special handling.
if ($_i == 'fields') {
$rows = array(
array(
'Key',
'Type',
'Name',
'Label',
),
);
_salesforce_api_drush_get_fields($response, $rows);
drush_print_table($rows, TRUE);
}
else {
$rows = array(
array(
dt('Key'),
dt('Value'),
),
);
_salesforce_api_drush_get_info($response, $rows);
drush_print_table($rows, TRUE);
}
} catch (Exception $e) {
drush_print($e->faultstring);
}
}
}
else {
drush_print('Could not connect to Salesforce.');
}
}