Probably ridiculous Coldfusion Database question..

Discussion in 'Web Design and Development' started by suzierthanyou, Apr 12, 2009.

  1. suzierthanyou macrumors newbie

    Joined:
    Apr 12, 2009
    #1
    Right, I'm going to sound like a total idiot, so please bear with me.

    I'm trying to get started making a coldfusion based website. I've made one ONCE before in one night and didn't really understand what the hell I was doing and scraped through by using someone else's as a template.

    I seem to need Access, but I've established I can't get it for mac. How do I make my database?? All I want is to make a nice database and then go from there...but I've been downloading all sorts of scary things and nothing is looking right so far. Basically, what on earth do I do?!?!?!
     
  2. Gmaster macrumors member

    Joined:
    Nov 8, 2005
    Location:
    Florida
    #2
    This isn't the full solution, because I don't know the exact answer, but I think this may help you get to where you need.

    It seems databases for Coldfusion are just repositories; the tables are there for your data (reads and writes). Therefore, even with Access, only the tables are used (not the reports, queries, forms, etc.).

    I'm thinking that you will want to use MySQL for your database.

    For development, you'll want to download CF from Adobe, and install it. (CF server is free for development use; development use means you get the full version, except only one (or two?) systems can connect to it simultaneously). Put CF server right on your Mac.

    Choose your coding program. Now you can develop and test on your Mac.
    When it is time to upload to the web, be certain your host offers Coldfusion. You will probably need to give them a few hours to connect your database to be a valid data source.

    The problem is, I am not familiar with MySQL. Maybe another forum member can assist with that.
     
  3. SrWebDeveloper macrumors 68000

    SrWebDeveloper

    Joined:
    Dec 7, 2007
    Location:
    Alexandria, VA, USA
    #3
    Once a MySQL server is up and running fine, configure CF to use that connection by going into CFAdmin and setting up a new MySQL connection using ODBC as the connection type (or myODBC if supported). Just supply a datasource name you make up, the database name, the hostname or IP or Local Host, username, password, and port which is 3306, the other options you can play with, but those are the essentials.

    Here is help on how to setup CF to use MySQL.

    Then in CF code you can query and retreive results via MySQL as follows (simple examples below to demonstrate the concept):

    Code:
    // dsn = data source name as configured in CFAdmin for MySQL...
    
    <cfquery name="get_names" datasource="#dsn#">
    	   SELECT name FROM table_of_names
    </cfquery>
    
    // Retreive results...
    
    <cfloop query="get_names">
    	   #get_names.name#<br/>
    </cfloop>
    
    Which means use cfquery tag for your queries passing the dsn name, use the name attribute in getting your results, i.e. name.field_name which you set in your query. Simple as that. If you do not understand this, read some tutorials on CF and MySQL, plenty available via Google. Requires basic knowledge of how databases work, how to create queries, and how to loop through result sets. If not experienced with basic database usage, plenty of online guides for MySQL setup as well.

    -jim
     

Share This Page