{"action":"closed","issue":{"url":"https://api.github.com/repos/RESTful-Drupal/restful/issues/697","labels_url":"https://api.github.com/repos/RESTful-Drupal/restful/issues/697/labels{/name}","comments_url":"https://api.github.com/repos/RESTful-Drupal/restful/issues/697/comments","events_url":"https://api.github.com/repos/RESTful-Drupal/restful/issues/697/events","html_url":"https://github.com/RESTful-Drupal/restful/issues/697","id":112718572,"number":697,"title":"Secondary (Non-Drupal) database; PR useful?","user":{"login":"jeff-h","id":841871,"avatar_url":"https://avatars.githubusercontent.com/u/841871?v=3","gravatar_id":"","url":"https://api.github.com/users/jeff-h","html_url":"https://github.com/jeff-h","followers_url":"https://api.github.com/users/jeff-h/followers","following_url":"https://api.github.com/users/jeff-h/following{/other_user}","gists_url":"https://api.github.com/users/jeff-h/gists{/gist_id}","starred_url":"https://api.github.com/users/jeff-h/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeff-h/subscriptions","organizations_url":"https://api.github.com/users/jeff-h/orgs","repos_url":"https://api.github.com/users/jeff-h/repos","events_url":"https://api.github.com/users/jeff-h/events{/privacy}","received_events_url":"https://api.github.com/users/jeff-h/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-10-22T02:28:09Z","updated_at":"2015-10-22T21:27:03Z","closed_at":"2015-10-22T21:27:03Z","body":"I needed to define a resource which pulls data from a secondary database (defined in `settings.php`). It was pretty trivial to override `getQuery()` so instead of:\r\n\r\n```php\r\n  /**\r\n   * Get a basic query object.\r\n   *\r\n   * @return SelectQuery\r\n   *   A new SelectQuery object for this connection.\r\n   */\r\n  protected function getQuery() {\r\n    $table = $this->getTableName();\r\n    return db_select($table)->fields($table);\r\n  }\r\n```\r\n\r\nI have\r\n\r\n```php\r\n  /**\r\n   * Get a basic query object.\r\n   *\r\n   * @return SelectQuery\r\n   *   A new SelectQuery object for this connection.\r\n   */\r\n  protected function getQuery() {\r\n    $connection = $this->getConnection();\r\n    $table = $this->getTableName();\r\n    \r\n    return Database::getConnection($connection->target, $connection->key)->select($table)->fields($table);\r\n  }\r\n```\r\n\r\nand pull the connection from a new key in the plugin info array.\r\n\r\nI was wondering if you'd like this in a PR or whether it's too specialised a case and too easily implemented as a one-off to be bothered. Let me know.\r\n\r\nIf not a PR, I'll stick it in the wiki recipes."}}