Skip to main content
Inspiring
February 16, 2009
Question

mysql database select

  • February 16, 2009
  • 1 reply
  • 914 views
Hi Guys! I am working on Mysql Project and I list all the dsn's using coldfusion admin APi Command. I get the list of all dsn fine.

i selected the datasource of mysql which i created as test. TEST is the DSN Nam and TestTable is the DATABASE NAME.

Now i use this DSN and i want to list all the tables of the DATABASE .

i use something like like:

select full tables FROM [DatabaseName]

Well i have only DSN variable with me how can i get the [DatabaseName] to fit in the above query and get all the table Names related to that database.
This topic has been closed for replies.

1 reply

Inspiring
February 16, 2009
this should give you all the tables in the db associated with the given
dsn if you are on CF8:

<cfdbinfo datasource="[name_of_your_dsn_here]" name="mydbtables"
type="tables">
<cfdump var="#mydbtables#">

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Inspiring
February 16, 2009
unfortunately i am not on CF8 and more importantly i can see all datasources registered with the coldfusion admin.

Only i want something like:

select full tables from [database]

but what i have is datasource, so i can get database Name registered with the datasource

Regards
Inspiring
February 16, 2009
Oh Ok I got it working somehow but every time i run with different database it gets column Names like:

TABLES_IN_DatabaseName

Now what i am trying is showing tables realted to the database.

Every time i select different Datasource related to mysql. it returns column Names as:

TABLES_IN_DatabaseName1

Now i used this function as:

<cfset dbName = listGetAt(list.columnList,3,"_")>

<cfoutput>#evaluate("tables_in_"&dbName)#</cfoutput>

to get the last database Name

but it is showing an error as:

Error Occurred While Processing Request
Invalid CFML construct found on line 1 at column 21.
ColdFusion was looking at the following text:

,

The error occurred in C:\Inetpub\wwwroot\p1\index.cfm: line 109

107 : <tr>
108 : <td>
109 : <cfoutput>#evaluate("tables_in_"&dbName)#</cfoutput>
110 : <cfelse>
111 : #name#


I am struggling with these fom the start of day and now my brain totally gone off

can anyone please help me in this

Cheers