0

I have a user search module in drupal that creates contact cards base on LDAP user information. Everything works fine, I just need to make it more flexible, so that if the same module is used in a different drupal install, it can just set the same ldap server that is set in drupal. Currently it is hard-coded.

first, I tried using this to get the server info:

  $ldapServer = db_query("SELECT address FROM ldap_servers WHERE `binddn` = 'cn=Directory Manager'");
  print_r( $ldapServer);

This is what the query returned:

DatabaseStatementBase Object ( [dbh] => DatabaseConnection_mysql Object ( [needsCleanup:protected] => [target:protected] => default [key:protected] => default [logger:protected] => [transactionLayers:protected] => Array ( ) [driverClasses:protected] => Array ( [MergeQuery] => MergeQuery [SelectQuery] => SelectQuery [UpdateQuery] => UpdateQuery [InsertQuery] => InsertQuery_mysql ) [statementClass:protected] => DatabaseStatementBase [transactionSupport:protected] => 1 [transactionalDDLSupport:protected] => [temporaryNameIndex:protected] => 0 [connectionOptions:protected] => Array ( [database] => tlsconnectapp [username] => drupal [password] => drupal [host] => localhost [port] => [driver] => mysql [prefix] => Array ( [default] => ) ) [schema:protected] => [prefixes:protected] => Array ( [default] => ) [prefixSearch:protected] => Array ( [0] => { [1] => } ) [prefixReplace:protected] => Array ( [0] => [1] => ) ) [queryString] => SELECT address FROM ldap_servers WHERE binddn = 'cn=Directory Manager' )

I'm sure I did something wrong, but I'm not sure what this means, and the server isn't in there.

1
  • I've also tried just using SELECT address FROM ldap_servers and get the same result.
    – slpcc63
    Feb 26, 2014 at 22:24

1 Answer 1

0

Please read on Working with Result Sets documentation. You have not issued the query yet to your database, you've only built a SELECT statement.

I also recommend installing the Devel module as you can get much more readable debug information from dpq() for queries or dpm() for Objects you want to inspect.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.