Child pages
  • UAPI Functions - Mysql::list_routines
Skip to end of metadata
Go to start of metadata

Description

This function returns a database user's MySQL® routines.

Important:

When you disable the MySQL role, the system disables this function. For more information, read our How to Use Server Profiles documentation.

Examples 


 cPanel or Webmail Session URL
https://hostname.example.com:2083/cpsess##########/execute/Mysql/list_routines?database_user=db_user


Note:

This example calls the UAPI function via a cPanel session. For more information, read our Guide to UAPI documentation. 

 LiveAPI PHP Class
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// List the routines for the db_user's database.
$list_routines = $cpanel->uapi(
    'Mysql', 'list_routines', 
    array(
        'database_user'   => 'db_user',
 ) 
);


Note:

For more information, read our Guide to the LiveAPI System.

 LiveAPI Perl Module
my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# List the routines for the db_user's database.
my $list_routines = $cpliveapi->uapi(
    'Mysql', 'list_routines',
    { 
        'database_user'   => 'db_user',
    }
);


Note:

For more information, read our Guide to the LiveAPI System.

 Command Line
uapi --user=username Mysql list_routines database_user=db_user


Notes:

  • You must URI-encode values.
  • username represents your account-level username.
  • For more information and additional output options, read our Guide to UAPI documentation or run the uapi --help command. 
  • If you run CloudLinux™, you must use the full path of the uapi command:

    /usr/local/cpanel/bin/uapi


 Output (JSON)
{
   "func": "list_routines",
   "module": "Mysql",
   "result": {
      "data": [
         "cptest_newdb.hello",
         "cptest_newdb.my_routine"
      ],
      "errors": null,
      "messages": null,
      "metadata": {
         "transformed": 1
      },
      "status": 1,
      "warnings": null
   }
}


Note:

Use cPanel's API Shell interface (cPanel >> Home >> Advanced >> API Shell) to directly test cPanel API calls.

Parameters

ParameterTypeDescriptionPossible valuesExample
database_userstring

The database user for whom to return MySQL routines.

If you don't specify a database user, this function returns the MySQL routines for all database users.

A valid database username.db_user

Returns

Return TypeDescriptionPossible valuesExample
dataarray

An array of MySQL routines.

If no routines exist, the function returns an empty array.

An array of MySQL routines.

cptest_newdb.hello, cptest_newdb.my_routine