showDatabaseTablesMySQL(Path, Database [, Timeout])
Last updated June 4, 2004
Version: 1 | Requires: ColdFusion MX | Library: DatabaseLib
Description:
This function will return a MySQL database and all child tables as an array
without using a cfquery.
provide the argument "path" which is the path to the mySql\bin directory being used.
provide the argument "database" which is the name of the MySQL database.
if necessary, provide the argument "timeout" which is the timeout in seconds for the request
Return Values:
Returns an array.
Example:
x = showDatabaseTablesMySQL('c:\mySql\bin', 'myDatabase', '30');
</cfscript>
<cfdump var="#x#">
Parameters:
| Name | Description | Required |
|---|---|---|
| Path | Path to where mysqlshow exists. | Yes |
| Database | Database to inspect. | Yes |
| Timeout | Time to wait for results. Defaults to 30. | No |
Full UDF Source:
<!---
This function will return all child tables of a mySQL database as an array.
@param Path Path to where mysqlshow exists. (Required)
@param Database Database to inspect. (Required)
@param Timeout Time to wait for results. Defaults to 30. (Optional)
@return Returns an array.
@author brandon wyckoff (bwyckoff2@cox.net)
@version 1, June 4, 2004
--->
<cffunction name="showDatabaseTablesMySQL">
<cfargument name="path" required="true">
<cfargument name="database" required="true">
<cfargument name="timeout" required="false" default="30">
<cfscript>
var a = "";
var x = "";
var y = 1;
database=replace(database, '_', '\_', 'all');
</cfscript>
<cfexecute name="#arguments.path#\mysqlshow" arguments="#arguments.database#" timeout="#arguments.timeout#" variable="mySQLDB"></cfexecute>
<cfscript>
a=replaceList(mySQLDB,'+,-, ,','');
a=trim(a);
x=arrayNew(1);
</cfscript>
<cfloop list="#a#" index="i" delimiters="|">
<cfscript>
if (not compareNoCase(left(i, 9), "Database:")) {
} else if (not compareNoCase(trim(replace(i, '|', '', 'all')),"Tables")) {
x = arrayNew(1);
} else if (compareNoCase(trim(i), "")) {
x[y]=i;
y=y+1;
}
</cfscript>
</cfloop>
<cfreturn x>
</cffunction>
Search CFLib.org
Latest Additions
Tayo Akinmade added
arrayTrim
11 day(s) ago
Will Belden added
longTime
17 day(s) ago
James Sleeman added
quickSort
27 day(s) ago
Ben Forta added
GetHostAddress
30 day(s) ago
Top Rated
EksporSQLData
Rated 5.0, 16 time(s)
backupDatabase
Rated 5.0, 13 time(s)
indentXml
Rated 5.0, 10 time(s)
generateSsccAsn
Rated 5.0, 4 time(s)