I'm trying to write code for a CCK php-drivien page that will check to see if a drupal user on my site is also a current member within CiviCRM. I have a separate CiviCRM database. In my other incarnation as an ASP coder, I'd use a connection string to gain access to a database. I need something like that to get around the following error message:
=========
user warning: SELECT command denied to user '[my drupal database username] '@'209.xx.x.x' for table 'civicrm_membership_status' query: SELECT * FROM tilthpro_tpw1civicrm.civicrm_membership_status, tilthpro_tpw1civicrm.civicrm_uf_match WHERE tilthpro_tpw1civicrm.civicrm_uf_match.uf_id =1 in /usr/www/users/tilthpro/includes/database.mysqli.inc on line 151.
===========
The code I used was:
<?
$result = db_query('SELECT * FROM tilthpro_tpw1civicrm.civicrm_membership_status, tilthpro_tpw1civicrm.civicrm_uf_match WHERE tilthpro_tpw1civicrm.civicrm_uf_match.uf_id =1');
while ($field = db_fetch_object($result)) {
if ( $field->is_current_member == "1" ) {
print ("Yes!");
}
else {
print ("No!");
}
}
?>Can someone give me a sample database connection string that would connect me with my CiviCRM database from within a Drupal node?
Comments
CiviNode And Civinode CCK
you might want to check out CiviNode And Civinode CCK
http://drupal.org/project/civinode
CiviNode is a module and API that exposes CiviCRM contacts, groups, and other CiviCRM object types to Drupal as nodes. It's designed to make CiviCRM easier to use and integrate with all of the Drupal tools and techniques you've come to know and love. For example, once you've mirrored a CiviCRM contact into Drupal, you will be able to:
* Catagorize it with taxonomies
* Attach event or location information
* Track what's happening with the contact with a work-flow
* Control the way it displays by theming it.
The project will also include:
* An "easy-to-use" wrapper API for handling common programming tasks that modules using CiviCRM can use.
* Support for CCK: you can add a "contact" or a CiviCRM group to your new content types, with support for formatters.
* Support for Views: you can display contact fields (e.g., 'first_name', 'sort_name', 'city', 'phone'), or display a contact using CiviCRM profiles.
-------------------
http://www.PrivacyDigest.com/ News from the Privacy Front (Drupal)
http://www.SunflowerChildren.org/ Helping children around the world ( Drupal)
Do I need to change settings.php for mulitple connections?
I'm not sure that MacRonin's suggestion is what I need for this, but I'll look at it anyway.
However, in studying db connections, in the Drupal settings.php file I find this:
To specify multiple connections to be used in your site (i.e. for
* complex custom modules) you can also specify an associative array
* of $db_url variables with the 'default' element used until otherwise
* requested.
You see, I took the advice to set up CiviCRM with its own database ("complex custom module" as referenced above), so it looks like I need to set up an associative array and have both $db_urls in it.
So, what I need to know is how to replace the following in my settings.php with an associative array:
$db_url = 'mysqli://[username]:[password]@[mysqlhost]/[mysqldbname]';Also how to set the "default element" in this array and how to request the non-default element in a connection string within a CCK generated php node.
What would such a connection string look like?
Did you solve this?
I'm trying to do the same thing. i'm hoping that by using GRANT ALL PRIVILEGES for the Drupal MySQL login to everything in the CiviCRM database, it's work.