CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Strange Issue with Query
Pages: [1]

Author Topic: Strange Issue with Query  (Read 723 times)

qjensen

  • I post frequently
  • ***
  • Posts: 141
  • Karma: 11
    • Scaled Solutions
  • CiviCRM version: 4.5
  • CMS version: Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Strange Issue with Query
September 09, 2010, 09:13:36 am
I am working on a new module for one of my customers. As part of the module I create a simple table that is used just to map group id numbers to price set field option ids. I was going through doing some refactoring and found a piece of code that was identical in 2 hook calls so I broke it out into its own function. The function is identical to the original code, but never returns anything. It worked fine when it was inside my original hook implementations.

Code: [Select]
//retrieve list of groups allowed to access
//the price option field.
//if nothing is returned then all users
//have access
function getAcl($oid){
    $aces = array();
    $q = "SELECT * FROM civicrm_memberprice WHERE oid= %1";
    $params=array(1=>array($oid,'Integer'));
    $dao = CRM_Core_DAO::executeQuery( $q, $params );
    while($dao->fetch){
        array_push($aces, $dao->gid);
        print "GID is ".$dao->gid; //nothing ever gets printed here
    }
    return $aces;
}

I uncommented
Code: [Select]
//CRM_Core_Error::debug( 'q', $queryStr ); in DAO.php to get a good look at what was happening behind the scenes, and everything was correct. I am not getting any error message, not getting anything.

Where can I go from here to find the source of the problem?

Thanks for any direction,
Quint Jensen
Web Developer
Scaled Solutions
--" Remove the 'I want you to like me' notes from your forehead and place them where they truly will do the most good -- on your mirror!" Author Unknown

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Strange Issue with Query
September 09, 2010, 10:54:39 am

1. check mysql query log and see what query is generated and what is returned

2. add a few debug statements in the while loop

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

qjensen

  • I post frequently
  • ***
  • Posts: 141
  • Karma: 11
    • Scaled Solutions
  • CiviCRM version: 4.5
  • CMS version: Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Strange Issue with Query
September 09, 2010, 01:44:47 pm
OK - I am a monkey

$dao->fetch should be $dao->fetch()

I will now step away from the computer for a while.
Quint Jensen
Web Developer
Scaled Solutions
--" Remove the 'I want you to like me' notes from your forehead and place them where they truly will do the most good -- on your mirror!" Author Unknown

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Strange Issue with Query

This forum was archived on 2017-11-26.