Name

DBI::func

Synopsis

$handle->func(@func_arguments, $func_name);
@dbs = $db->func(“$hostname”, '_ListDBs');
@dbs = $db->func(“$hostname:$port”, '_ListDBs');
@tables = $db->func('_ListTables');
$result = $drh->func( $database, '_CreateDB’ );
$result = $drh->func( $database, '_DropDB’ );

DBI::func calls specialized nonportable functions included with the various DBD drivers. It can be used with either a database or a statement handle depending on the purpose of the specialized function. If possible, you should use a portable DBI equivalent function. When using a specialized function, the function arguments are passed as a scalar first followed by the function name. DBD::mSQL and DBD::mysql implement the following functions:

_ListDBs

The _ListDBs function takes a hostname and optional port number and returns a list of the databases available on that server. It is better to use the portable function DBI::data_sources.

_ListTables

The _ListTables function returns a list of the tables present in the current database.

_CreateDB

The _CreateDB function takes the name of a database as its argument and attempts to create that database on the server. You must have permission to create databases for this function to work. The function returns -1 on failure and on success.

_DropDB

The _DropDB function takes the name of a database as its argument and attempts to delete that database from the server. This function does not prompt the user in any way, and if successful, the database will be irrevocably ...

Get MySQL and mSQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.