2 Replies Latest reply on Aug 30, 2006 8:33 AM by @shortfused

    Dynamic database Structures

    Nightfall_Blue Level 1
      Hi, Im trying to set up a site so the admin user can list the contents of any database using one template, and an argument (code) being passed in the URL string.

      So far all is working fine. It gets the structures table ID and field infor from the URL code just fine

      except I'm struggling getting the actual DATA stored displaying.

      Anyone got any tips?

        • 1. Re: Dynamic database Structures
          Nightfall_Blue Level 1
          I've managed to tidy this up a great deal and have fathomed a couple ofd places where I'm stuck.


          <cfdump label="row content" var="#this_row_content#">
          <cfdump label="cell content" var="#this_cell_content#">
          are not working

          <cfdump label="row content" var="#this_row_content#"> is outputting all rows in the query "table_field_content". whereas it was intended to only contain the single row whose value was set by #request.rowcounter#

          <cfdump label="cell content" var="#this_cell_content#"> does the same. In addition when I want to output it I am going to need to refer to the table field names (which are in the query "table_fields"), yet I cannot reference them as the cfloop around the name of the field leaves and extra comma which creates a syntax error.

          Any ideas?

          • 2. Re: Dynamic database Structures
            cfdump will output the entire content of the variable, be it a simple value or struct.

            I would quickly build a database viewer like this:

            <cfif isDefined("FORM.submit") and FORM.submit neq ''>
            <cfquery name="tb_dump" datasource="#your_datasource#">
            SELECT * FROM #FORM.db_tables#
            <cfdump var="#tb_dump#">
            <cfform name="db_dump" format="html" action="">
            <cfselect name="db_tables">
            <option value="table1">table1</option>
            <option value="table2">table2</option>
            <option value="table3">table3</option>
            <option value="table4">table4</option>
            <option value="table5">table5</option>
            <cfinput type="submit" name="submit" value="Do it">

            You could dynamically populate the select list from a query also.