Answers.Body: <p>Perhaps you missed this step:
  <a href="https://docs.civicrm.org/sysadmin/en/latest/integration/drupal/views/" rel="nofollow noreferrer">https://docs.civicrm.org/sysadmin/en/latest/integration/drupal/views/</a></p>
  
  <blockquote>
    <ol>
    <li>Before making any changes, it is strongly advised that you make backups of your mysql databases and settings.php file.  </li>
    <li>If you have different database users for your CiviCRM and Drupal databases, then you need to grant SELECT access for the Drupal user to all the CiviCRM tables.  </li>
    <li>Make sure you are logged into your Drupal site as the administrator.</li>
    <li>Visit <a href="http://example.org/civicrm/admin/setting/uf?reset=1" rel="nofollow noreferrer">http://example.org/civicrm/admin/setting/uf?reset=1</a>  </li>
    <li>You should see a page with output that begins with: <code>$databases['default']['default']['prefix']= array(</code>  </li>
    <li>Copy this setting output, including the trailing <code>);</code></li>
    <li>Open <code>/sites/default/settings.php</code> for editing from the root directory of the site, typically <code>public_html</code> on most servers.
    
    <blockquote>
      <p>Note: This assumes you have a single site installation. The location of the settings file might be different depending on whether or not you have multiple sites</p>
    </blockquote></li>
    <li>Find the database connector array. This is where Drupal stores the information regarding the MySQL database and the necessary credentials to connect to it. The array beings with <code>$databases = array (</code> then goes on to include the location and MySQL credentials, as well as additional options.</li>
    <li>Paste your previously-copied settings output here. Be sure to paste it after the trailing <code>);</code></li>
    <li>You may need to indicate the default prefix. If you see an error [like] <code>PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'kckruppc_every.semaphore' doesn't exist: SELECT ...</code> You need to include an additional line, <code>'default' =&gt; '&lt;drupaltableprefix&gt;'</code>, in your settings.php just after <code>$database ['default']['default']['prefix']= array(</code>. …  </li>
    <li>Save the file. You might want to clear your site cache at this point.</li>
    <li>You should now be able to create views based on CiviCRM data.</li>
    </ol>
  </blockquote>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-14T16:09:01.233Z
Answers.LastActivityDate: 2018-01-30T22:01:33.997Z
Answers.LastEditDate: 2018-01-30T22:01:33.997Z
Answers.UserDisplayName: KarinG - Semper IT
Answers.Body: <p>As a test you could install the CiviCRM Entity module, that provides views integration in a different way than core. If that doesn't work then something strange is happening for sure</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-14T05:00:52.837Z
Answers.LastActivityDate: 2018-01-14T05:00:52.837Z
Answers.UserDisplayName: jackrabbithanna
Answers.Body: <p>Like KarinG said, there is a step needed to tell Drupal about CiviCRM's database tables. That is described at <a href="https://docs.civicrm.org/sysadmin/en/latest/integration/drupal/views/" rel="nofollow noreferrer">https://docs.civicrm.org/sysadmin/en/latest/integration/drupal/views/</a>. This involves editing your Drupal settings.php file and pasting code provided by CiviCRM. </p>
  
  <p>This has worked well for me, and I have this working on a live site right now. Some of the queries you can run with this in Views are a bit limited compared to native Drupal node queries, but it does work.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-30T18:23:13.520Z
Answers.LastActivityDate: 2018-01-30T18:23:13.520Z
Answers.UserDisplayName: Casper Voogt
Body: <p>I have CiviCRM 4.7.28, Drupal 7.56 and Views 7.x-3.18 and have CiviCRM and Drupal in the same database.</p>
  
  <p>I have read in the documentation that Views should work out of the box, and most of the issues relating to CiviCRM and Views is to configure setup if CiviCRM and Drupal are on different databases.</p>
  
  <p>Any tip much appreciated!</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-12-22T22:12:28.600Z
Comments.Text: Can you be more specific about what you mean by "not working"?
Comments.UserDisplayName: choster
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-12-22T22:18:33.413Z
Comments.Text: When I go into Views, I don’t any CiviCRM tables to select
Comments.UserDisplayName: Flying
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-12-23T00:25:59.770Z
Comments.Text: when you go to create a new view, are you given any civicrm options in the top menu? (Show:) 
  if you are in a view that is not based in a civicrm contact/activity/etc. you should also be able to see civi options when adding a new Relationship, do you have those options?
Comments.UserDisplayName: ericG
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-12-23T00:56:04.697Z
Comments.Text: @ericG no, I have no CiviCRM options on the top menu
Comments.UserDisplayName: Flying
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-12-24T01:29:42.757Z
Comments.Text: strange. I've never had a problem with this. even though they are in one db, maybe try to put the section in the config file anyway? worth a try. 
  /civicrm/admin/setting/uf?reset=1  will give you the info to paste into the settings.php file
Comments.UserDisplayName: ericG
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-12-26T11:29:19.573Z
Comments.Text: Try clearing views cache OR `drush cc all`
Comments.UserDisplayName: jitendra - fuzion
Tags: <drupal-views>
Title: Drupal Views and CiviCRM on same database not working
ThreadText: # Drupal Views and CiviCRM on same database not working
  
  (Asked by: username_0 on 2017-12-22)
  
  I have CiviCRM 4.7.28, Drupal 7.56 and Views 7.x-3.18 and have CiviCRM and Drupal in the same database.
  
  I have read in the documentation that Views should work out of the box, and most of the issues relating to CiviCRM and Views is to configure setup if CiviCRM and Drupal are on different databases.
  
  Any tip much appreciated!
  
  **Tags:** drupal-views
  
  > **Comments:**
  > **username_1**: Can you be more specific about what you mean by "not working"?  
  > **username_0**: When I go into Views, I don’t any CiviCRM tables to select  
  > **username_2**: when you go to create a new view, are you given any civicrm options in the top menu? (Show:)  if you are in a view that is not based in a civicrm contact/activity/etc. you should also be able to see civi options when adding a new Relationship, do you have those options?  
  > **username_0**: @username_2 no, I have no CiviCRM options on the top menu  
  > **username_2**: strange. I've never had a problem with this. even though they are in one db, maybe try to put the section in the config file anyway? worth a try.  /civicrm/admin/setting/uf?reset=1  will give you the info to paste into the settings.php file  
  > **username_3**: Try clearing views cache OR `drush cc all`  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_4 on 2018-01-14. Score: 2
  
  Perhaps you missed this step:
  <https://docs.civicrm.org/sysadmin/en/latest/integration/drupal/views/>
  
  > 1. Before making any changes, it is strongly advised that you make backups of your mysql databases and settings.php file.
  > 2. If you have different database users for your CiviCRM and Drupal databases, then you need to grant SELECT access for the Drupal user to all the CiviCRM tables.
  > 3. Make sure you are logged into your Drupal site as the administrator.
  > 4. Visit <http://example.org/civicrm/admin/setting/uf?reset=1>
  > 5. You should see a page with output that begins with: `$databases['default']['default']['prefix']= array(`
  > 6. Copy this setting output, including the trailing `);`
  > 7. Open `/sites/default/settings.php` for editing from the root directory of the site, typically `public_html` on most servers.
  >    > Note: This assumes you have a single site installation. The location of the settings file might be different depending on whether or not you have multiple sites
  > 8. Find the database connector array. This is where Drupal stores the information regarding the MySQL database and the necessary credentials to connect to it. The array beings with `$databases = array (` then goes on to include the location and MySQL credentials, as well as additional options.
  > 9. Paste your previously-copied settings output here. Be sure to paste it after the trailing `);`
  > 10. You may need to indicate the default prefix. If you see an error [like] `PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'kckruppc_every.semaphore' doesn't exist: SELECT ...` You need to include an additional line, `'default' => ''`, in your settings.php just after `$database ['default']['default']['prefix']= array(`. …
  > 11. Save the file. You might want to clear your site cache at this point.
  > 12. You should now be able to create views based on CiviCRM data.
  
  
  ---
  
  ### Answer by username_5 on 2018-01-14. Score: 0
  
  As a test you could install the CiviCRM Entity module, that provides views integration in a different way than core. If that doesn't work then something strange is happening for sure
  
  
  ---
  
  ### Answer by username_6 on 2018-01-30. Score: 0
  
  Like KarinG said, there is a step needed to tell Drupal about CiviCRM's database tables. That is described at <https://docs.civicrm.org/sysadmin/en/latest/integration/drupal/views/>. This involves editing your Drupal settings.php file and pasting code provided by CiviCRM.
  
  This has worked well for me, and I have this working on a live site right now. Some of the queries you can run with this in Views are a bit limited compared to native Drupal node queries, but it does work.
  
  
  ---
  
  