We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11413
    • 203 Posts
    Hi again with AJAX!

    I’m creating an independant php file for each request handler... it works fine, but how can I use the DB api inside them? I can use it everywhere in my module, but the ajax request handlers are called in a separate thread wich is not logged in the manager and parsed by MODx...

    So, the only way I could imagine would be to find a way of calling a snippet or something like that.... could you help me there?

    thanks a lot in advance,

    Blaise
      Blaise Bernier

      www.medialdesign.com - Solutions for small business, hosting, design and more!
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      You can’t. Unless you are willing to include the document.parser.class.inc.php file, in start a new modx class. And even then, you’ll have problems with the include paths that the parser uses internally for including the db api class. I found the best way is to include the config.inc.php file for the database info and use straight mysql_xxx php functions. The DBAPI makes several calls to modx class methods, so it cannot be used by itself.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 11413
        • 203 Posts
        ok... ill go with the config.inc.php!

        Thanks!
          Blaise Bernier

          www.medialdesign.com - Solutions for small business, hosting, design and more!
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          If you really use a lot of sql in your scripts, you could use a dbapi library of your own; my favorite for years has been ezsql; in fact I was a little disappointed the MODx team decided to roll their own rather than go with this one. WordPress uses it.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 7885
            • 40 Posts
            Quote from: grunt_lord at Mar 16, 2006, 12:05 AM

            Hi again with AJAX!

            I’m creating an independant php file for each request handler... it works fine, but how can I use the DB api inside them? I can use it everywhere in my module, but the ajax request handlers are called in a separate thread wich is not logged in the manager and parsed by MODx...

            So, the only way I could imagine would be to find a way of calling a snippet or something like that.... could you help me there?

            thanks a lot in advance,

            Blaise

            i have the solution for this ajax related problem!
            i’ll post in a wiki today with examples and all, plase be patient, it’s a good solution i guess... worth the look
              visit us at www.dospuntocero.cl
              • 22303 MODX Staff
              • 10,725 Posts
              Quote from: sottwell at Mar 16, 2006, 12:38 AM

              If you really use a lot of sql in your scripts, you could use a dbapi library of your own; my favorite for years has been ezsql; in fact I was a little disappointed the MODx team decided to roll their own rather than go with this one. WordPress uses it.
              Susan, I think you are mistaken with regards to data access libraries. Nothing was hand-rolled here as far as data access libraries are concerned; the MODx team chose PDO, which is the new standard for database access in PHP 5.1+. The only thing we chose to do is provide PHP 4 support for it by providing a PDO emulation layer for PHP 4 (or 5.0.x, or any PHP without the proper PDO drivers).

              xPDO is not a data access library. It is an object-relational mapping system that was hand-rolled on top of PDO, because no decent solution for PDO was available, and certainly not one that worked with PHP 4 as well.
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                Ah, that was long ago. I was referring to the dbapi.mysql.class.inc.php file, and a library of simple data access functions.

                Of course xpdo is a totally different matter of which I will freely admit I know nothing at all as yet.
                  Studying MODX in the desert - http://sottwell.com
                  Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                  Join the Slack Community - http://modx.org
                  • 7885
                  • 40 Posts
                  ok as i promised, i post this page to the wiki, i hope this works for you and if the comunity can perfect it will be nice start to see lots of ajax stuff in our beloved MODx laugh

                  http://wiki.modxcms.com/index.php/Use_AJAX_with_modxAPI
                    visit us at www.dospuntocero.cl
                    • 7231
                    • 4,205 Posts
                    Looks cool. I will give it a go as soon as I get some time. Thanks for posting this in the wiki.
                      [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                      Something is happening here, but you don't know what it is.
                      Do you, Mr. Jones? - [bob dylan]