CFLib.org – Common Function Library Project

showDatabaseTablesMySQL(Path, Database [, Timeout])

Last updated June 4, 2004

Version: 1 | Requires: ColdFusion MX | Library: DatabaseLib

 
Rated 0 time(s). Average Rating: 0

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:

view plain print about
<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:

view plain print about
<!---
 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>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Tayo Akinmade Tayo Akinmade added
arrayTrim
11 day(s) ago

Will Belden Will Belden added
longTime
17 day(s) ago

James Sleeman James Sleeman added
quickSort
27 day(s) ago

Ben Forta Ben Forta added
GetHostAddress
30 day(s) ago

Top Rated

Darwan Leonardo Sitepu EksporSQLData
Rated 5.0, 16 time(s)

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 13 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson