CFLib.org – Common Function Library Project

showDatabaseTablesMySQL(Path, Database[, Timeout])

Last updated June 04, 2004

author

brandon wyckoff

Version: 1 | Requires: CF6 | 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:

<cfscript>
 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

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson