Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

MysqlFE::listdbs modify output?

Discussion in 'cPanel Developers' started by arcuturus1, Nov 24, 2009.

  1. arcuturus1

    arcuturus1 Registered

    Joined:
    Nov 24, 2009
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    51
    PHP:
    public function listdbs($username) {
            if (!isset(
    $username)) {
                
    error_log("listdb requires that user is passed to it");
                return 
    false;
            }
            return 
    $this->api2_query($username'MysqlFE''listdbs');
        }


    *******************************************

    include(
    "xmlapi.php");

    $ip "*******";
    $root_pass "********";

    $account "******";

    $xmlapi = new xmlapi($ip);
    $xmlapi->password_auth("root",$root_pass);

    $xmlapi->set_debug(1);

    print 
    $xmlapi->api2_query($account'MysqlFE''listdbs');
    I'm running this code form an external php script, but it's out put is nothing. I can't see any thing...

    What I have to do to print list of databases....
     
  2. MattDees

    MattDees Well-Known Member

    Joined:
    Apr 29, 2005
    Messages:
    416
    Likes Received:
    1
    Trophy Points:
    243
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    $xmlapi->set_output('xml');
    print $xmlapi->api2_query($account, 'MysqlFE', 'listdbs');

    OR:

    print_r( $xmlapi->api2_query($account, 'MysqlFE', 'listdbs') );


    The API queries don't return strings by default, rather they return simplexml objects. (see: php.net/simplexml)

    You can either use the set_output() function to set the type of output you want (xml) or you can use print_r to display the object.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. arcuturus1

    arcuturus1 Registered

    Joined:
    Nov 24, 2009
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    51
    :):):)

    :)Thank you... It will help me.....
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice