We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31410
    • 66 Posts
    hello
    i need to use another database(not default modx) with modx CMF

    my snippet is like this
    $modx = new modX();
    //$modx->getContext(’web’);
    $modx->addPackage(’mappackage’,’model/’);
    $modx->getObject(’other_db_table_class’,3);

    when i tried to retrieve results from a table,iam not getting the results
    its not showing neither results nor errors

    can anyone tell me how to use different database in modx and also how can i enable debugging in modx

    Thank you
    venu


      • 31410
      • 66 Posts
      hello
      do i have to provide any other details here so that some can answer my query
      please tell me how to use two databases with modx revo

      thanks
      venu
        • 28215
        • 4,149 Posts
        Quote from: venu at Nov 12, 2009, 10:10 AM

        hello
        do i have to provide any other details here so that some can answer my query
        please tell me how to use two databases with modx revo

        thanks
        venu
        You wont be able to use the MODx object specifically. You can, however, instantiate a new instance of xPDO, which modX extends:

        http://svn.modxcms.com/docs/display/xPDO20/The+xPDO+Constructor
          shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
          • 31410
          • 66 Posts
          thank you
          its working by inializing new xpdo instance with other DB

          just want to know is that ok to use two or more database connections in same modx page

          thanks again for the reply

          venu
            • 28215
            • 4,149 Posts
            It’s harder on your server, since you’re maintaining two connections.

            But it’s up to you.
              shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
              • 32699 ☆ A M B ☆
              • 427 Posts
              Just to clarify:

              Database connections are now Persistent.

              You should simply pass your object around and keep using it until you are done.
                Get your copy of MODX Revolution Building the Web Your Way http://www.sanitypress.com/books/modx-revolution-building-the-web-your-way.html

                Check out my MODX || xPDO resources here: http://www.shawnwilkerson.com
                • 31410
                • 66 Posts
                hello
                not sure what iam missing in this query but always getting the same error that "Error preparing statement for query:"
                $query= new xPDOCriteria($this->mxpdo,’
                SELECT x,y FROM ’.$table.’
                WHERE `id` = :i1
                ’,array(’:i1’=>$id,));
                $data=$mxpdo->getObject(’myclass’,$query);

                even tried with xpdo query
                $query= $mxpdo->newQuery(’myclass’);
                $query->where(array(
                ’id’ => 18595,
                ));
                $data=$mxpdo->getCollection(’myclass’,$query);

                and also with $data=$mxpdo->getCollection(’myclass’,18595);

                not sure in that a problem with my schema
                but similar kind of query is working in another function

                iam using modx rev beta 4
                but this table is from another db,initiated xpdo for that table like the instructions given in docs

                thanks
                  • 31410
                  • 66 Posts
                  hello
                  the problem is solved with
                  $mxpdo->newquery($class,$id);

                  but when i try to debug xpdo with $mxpdo->setDebug();
                  the browser is going to offline mode iam always getting the message "page is not available"

                  is that problem with mysql or with my local apache server?

                    • 32699 ☆ A M B ☆
                    • 427 Posts
                    That’s a big question with plenty of possibilities.

                    1) What is your setup for OS , web server, etc.?
                    2) Are the system logs in the manager showing anything (Reports -> Error Log)
                    3) Are you using localhost, a dynamic dns, a domain name? Does your local hosts file have that name pointed to a 127.0.0.x?
                    4) Are you heading out via a router and getting cut off or redirected coming back in to the site?
                    5) Does your local name server redirect the name to the local computer, or are you even using a local name server?

                    If your site works, I would think the debug would work unless there is a redirect or something going on in your script. In many cases like this it is a syntactical error would may be revealed in the address bar or the browser error report.

                    Start with the simple stuff first -- check your syntax and make sure everything driving the browser is being sent the correct information.


                      Get your copy of MODX Revolution Building the Web Your Way http://www.sanitypress.com/books/modx-revolution-building-the-web-your-way.html

                      Check out my MODX || xPDO resources here: http://www.shawnwilkerson.com