Interested in improving this site? Please check the To Do page.

Back to MySQL Verbs

mysql.selectDatabase

Choose a new, active database

Syntax

mysql.selectDatabase(dbid, database)

Params

A database connection id, an existing database name

Returns

0 if successful, throws an error otherwise

Examples

on selectdatabase () {
	local (id, result, nameList);
	mysql.init();
	try {
		id = mysql.connect("127.0.0.1", "root", "frontier", "frontier", 3306)}
	else {
		dialog.alert(mysql.getErrorMessage(id));
		return false};
	nameList = mysql.getDatabaseNames(id);
	dialog.alert(nameList);
	nameList = mysql.getTableNames(id);
	dialog.alert(nameList);
	try {
		mysql.selectDatabase(id, "mysql")}
	else {
		dialog.alert(mysql.getErrorMessage(id));
		result = mysql.close(id);
		mysql.end();
		return false};
	nameList = mysql.getTableNames(id);
	dialog.alert(nameList);
	result = mysql.close(id);
	mysql.end();
	return result}
Dialogs return (in order):

	 » {"information_schema", "frontier", "mysql", "test"}
	 » {"names"}
	 » {"columns_priv", "db", "func", "help_category", "help_keyword", 
            "help_relation", "help_topic", "host", "proc", "procs_priv", 
            "tables_priv", "time_zone", "time_zone_leap_second", "time_zone_name",
            "time_zone_transition", "time_zone_transition_type", "user"}

Notes

none

See Also


Personal Tools