We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22656
    • 121 Posts
    Trying to get this to work, but i cannot find any documentation. Trying to migrate some evo code over, but not sure what to change in order to get everything to work "with minimal changes"!

    Original Example from Evo:
    $meQuery = $modx->db->query( "SELECT * from somewhere");
    $queryArray= $modx->db->makeArray( $meQuery );
    foreach ($queryArray as $result) {...}

    Code for Revo
    $meQuery = $modx->query( "SELECT * from somewhere");
    $queryArray= $modx->makeArray( $meQuery );
    foreach ($queryArray as $result) {...}

    but it fails on $modx->makeArray
    what should i do, is there an equivalent for makeArray in Revo?
    My head is in a sad sad place where there is no inspiration today! Thickness galore
      • 22303 MODX Staff
      • 10,725 Posts
      The DBAPI plugin provides the methods available in the DBAPI class so you don't have to migrate the code. But if you do want to migrate away from the DBAPI, and you use $modx->query, all you need to do is understand that what is returned is a standard PDOStatement object, which you can use as you would any PDOStatement.
        • 22656
        • 121 Posts
        Hmm thats what i thought, but if i leave my code as
        $modx->db->query( "SELECT * from somewhere");

        it fails on that line, claiming "Call to a member function query() on a non-object"?
        I have ensured DBAPI is installed and enabled...
          • 22656
          • 121 Posts
          mkay, got it to work.
          In plugin system events, i had to tick OnWebPageInit. This seems to have initialised the plugin... hopefully in the correct way.
            • 22303 MODX Staff
            • 10,725 Posts
            You should have been presented the option to register the Plugin with the appropriate events when installing it.