The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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:
    1
    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 cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    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.
     
  3. arcuturus1

    arcuturus1 Registered

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

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

Share This Page