1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Fetch Row Question

Discussion in 'XenForo Development Discussions' started by The1LT, Oct 22, 2013.

  1. The1LT

    The1LT Member

    Hi guys,

    Doing my first mod for an add on and as luck would have it, the code executes after the paypal callback and I can't figure out how to debug it with eclipse since it doesn't seem to pass off to paypal and return while in debug mode.

    So basically I'm coding/learning blind.

    Just a simple question:

    //get licence from table instead of randomly generating from helper class above       
            $used = 0;
            $row = $this->_getDb()->fetchRow("SELECT * FROM `gfnpm_license_import` WHERE Used = ? ORDER BY LicenceID", $used);   
            $newLicense = $row['LicenceKey'];
    Does the fetchRow function only return a single row when it's executed? This statement I've put together above I just want the last unused Licence entry to be returned. I had assumed that fetchRow was the same as a direct read or a chain and will only return the first it finds based on the params but when running it I'm getting some strange results as if it's picking up more than one row.

    So I looked around a bit further and found this type of statement:

    return $this->_getDb()->fetchOne('
                SELECT COUNT(*)
                FROM xf_conversation_user AS conversation_user
                INNER JOIN xf_conversation_master AS conversation_master ON
                    (conversation_user.conversation_id = conversation_master.conversation_id)
                INNER JOIN xf_conversation_recipient AS conversation_recipient ON
                    (conversation_user.conversation_id = conversation_recipient.conversation_id
                    AND conversation_user.owner_user_id = conversation_recipient.user_id)
                    ' . $sqlClauses['joinTables'] . '
                WHERE conversation_user.owner_user_id = ?
                    AND ' . $whereClause
            , $userId);
    So what would be the difference between a fetchRow and fetchOne?

    Again apologies for the basic question, i can't for the life of me get the debugger up on this one.

  2. The1LT

    The1LT Member

    As an aside if anyone knows how to run a paypal callback through the debugger that would probably be just as helpful.

    The problem I get is that when I run it in debug mode I get to the point where I click the button to send it off to paypal and then from there is doesn't open the new address. Just sits, so can't figure out how to get to the stage where it comes back to Xenforo with the IPN stuff for further processing.
  3. Chris D

    Chris D XenForo Developer Staff Member

    FetchOne will return a single value from a single field. FetchRow should return an entire row.

    To take the guess work out of what the query is returning you should dump the results of the query using one of the various PHP functions. I prefer to use Zend_Debug::dump($var);

    I've never played with the PayPal callback but I imagine paypal would return some sort of response. An external source probably isn't debuggable from an IDE.
    The1LT likes this.
  4. The1LT

    The1LT Member

    Cheers Chris, will look into using dump.

    This php is all very new to me.... Keep looking for the compile button.. lol
  5. The1LT

    The1LT Member

    I've actually managed to get this up and running with phpStorm, fortunately it does hold the session, so when paypal returns it automatically breaks again and you can step through the code handling the callback. Haven't gotten to the source of that "Security Error" issue yet but it's a start :)

Share This Page