We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34162
    • 1 Posts
    Maybe that’s mainly a documentation-issue:
    When looking around the forums here I see a lot of (db-related) stuff which is apparently not documented.
    "getFullTableName" (what’s the purpose of this one??) "getColumn", "fetchRow" and the like.
    Where can I find all this mysterious stuff? Or is it "developers only"?

    Is there any source for a more or less complete doc for these parts of the DBAPI?

    Now, coming to my current problem:
    All I wanted was plain simple: find the highest documentID, so I tried:

    $sql = "SELECT MAX(id) FROM ".$modx->getFullTableName("site_content");
    $result = $modx->db->query($sql);
    $row = $modx->fetchRow($result);
    echo $row;
    

    Result of the echo was merely "Array", not at all surprising - but how can I access this array?
    print_r should provide more info about the structure and content of that array, but using "print_r $row" in the module-source caused an error.

    Really don’t know how to continue coding undecided

    And BTW: How do the "pros" develop their more advanced stuff in the MODx environment?
    I guess this can hardly be done by typing or copy&paste in the manager’s php-source fields.
    Is it possible to get all that MODx system into an IDE, like Eclipse? So that I can see what’s really going on?
    Working without a debugger/IDE in a framework like MODx - impossible! At least for me...


      • 25663 MODX Staff
      • 12,272 Posts
      ppaul, there will be a lot coming in the future on that front. Not much in concrete, but clearly on the radar (IDE integration).
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 33175
        • 711 Posts
        Hi,

        You can look at the dbapi file into the folder manager/include.
        Personnally, Iwhen I need an access to the DB I look at this file.

        I am sorry to be not more precise but I am not at home and I do not remember any more of the exact name of this file.
          Sorry for my english. I'm french... My dictionary is near me, but it's only a dictionary !
          • 10487 MODX Staff
          • 1,535 Posts
          Hi ppaul,

          When using print_r, don’t forget the parentheses:
          print_r ($row);


          Then, to access the array, you just need to treat it as a normal associative array, for example:
          return $row['id'];


          Is it possible to get all that MODx system into an IDE, like Eclipse?
          Yes, absolutely - I do all my development on a local install of MODx and Eclipse (with phpEclipse plugin). Then, it’s a simple case of just copying and pasting the changes over to my live site.

          You can check out this tip by OpenGeek for the best way to reference snippets etc. from the filesystem when developing locally.

          To set up on Eclipse:

          1. Install Eclipse and the phpEclipse plugin
          2. Create a new PHP project in Eclipse and point it at the root of your local install.
          3. That’s it wink

          Hope that helps,
          Garry
            Garry Nutting
            Senior Developer
            MODX, LLC

            Email: [email protected]
            Twitter: @garryn
            Web: modx.com
            • 34162
            • 1 Posts
            Thanks for all those great tips and news!
            This forum is simply amazing! cool
              • 34162
              • 1 Posts
              @Guillaume:
              I am sorry to be not more precise but I am not at home and I do not remember any more of the exact name of this file.

              Just in case someone else needs this:
              Most, if not all, of the dbapi "secrets" I was complainin about are in:
              manager/includes/extenders/dbapi.mysql.class.inc.php

              And for the "strange" array:
              When using "SELECT MAX(id) FROM..."
              The array-key is exactly "MAX(id)": $row[’MAX(id)’] displays the id’s value.

              Just having created the Eclipse MODx project: Well, THAT looks different! grin