blog

Tuesday, July 22, 2008

Thursday, June 26, 2008

  • CFFORM validation issue with IIS on VPS

    It came as a suprice to me when i discovered that my cfform validation control was not working on a new VPS plan i just created.
    Although i known it was because it was a VPS, and i had to configure the whole thing myself.

    The support from the hosting company was no help at all. I was for striated. so i took the laws into my own hands.

    I search the net for possible solutions, but no luck. thou i didn't search for long.

    The problem is that the "CFIDE/scripts/mask.js" for example can not be display by the server. if i try something like this http://mysite.com/CFIDE/scripts/mask.js i get a 404 error message, meaning page can not be found, which not true.

    So i decide to go trough the IIS Manager for some explanation.
    At the end of the whole thing, i discovered that it was a MIME issue.

    by just adding text/javascript to the MIME list, everything in "CFIDE/scripts/*.js" became accessible











Friday, June 20, 2008

Thursday, June 12, 2008

  • Comparing columns in the same table (self-join?)

    A self-join is a query in which a table is joined (compared) to itself.
    I first thought about the self-join technique when i was building an e-commerce website (online shopping)
    It became something i needed to spend more time on when i start a project that needed one to create a dynamic category and store in database. a good example are files and folders.

    You can't for sure tell the number of folders/sub-folders the user is going to create.
    A simple database table design of the above example might look like this:


    My own design
    Note: the design below might not be the ideal design. its just to show self-join in action

    Strange Table Features
    • The folder table combines both file and folder table
    • The FolderId field is the Primary Key of the table
    • The ParentId field is the Id of the Parent Folder
    • The Name field serves as both foldername and filename
    Sample Table Data



    Relationships Between Columns



    Notice the "0" in the ParentId of "My Document" Record. This means any Record that has its Value set to "0" will be a Root directory.

    Putting everything together
    SELECT
        level1.FolderId,
        level1.ParentId,
        level1.Name AS Element1,
        level2.Name AS Element2,
        level3.Name AS Element3,
        level4.Name AS Element4,
        level5.Name AS Element5,
        level6.Name AS Element6
    FROM
    folder AS level1
        Inner Join folder AS level2 ON level1.FolderId = level2.ParentId   
        Left Join folder AS level3 ON level2.FolderId = level3.ParentId   
        Left Join folder AS level4 ON level3.FolderId = level4.ParentId 
        Left Join folder AS level5 ON level4.FolderId = level5.ParentId
        Left Join folder AS level6 ON level5.FolderId = level6.ParentId
    WHERE
        level1.ParentId =  0



    When i came up with this design, the first thing i was worried about was how to determine the number of table folder you will need to join.
    I have not figure out a pure sql statement for it yet.
    But the number of table folders needed is the number of the deepest child in the folder table. Lets save this part for another post.

    CF Code:

    <cfquery name="qFolder" datasource="dsn">
        SELECT
            level1.FolderId,
            level1.ParentId,
            level1.Name AS Element1,
            level2.Name AS Element2,
            level3.Name AS Element3,
            level4.Name AS Element4,
            level5.Name AS Element5,
            level6.Name AS Element6
        FROM
            folder AS level1
                Inner Join folder AS level2 ON level1.FolderId = level2.ParentId
               Left Join folder AS level3 ON level2.FolderId = level3.ParentId
                Left Join folder AS level4 ON level3.FolderId = level4.ParentId 
                Left Join folder AS level5 ON level4.FolderId = level5.ParentId
                Left Join folder AS level6 ON level5.FolderId = level6.ParentId
        WHERE
            level1.ParentId =  0
    </cfquery>

    <cfform name="pcdocument" format="flash" width="400" height="450" >
        <cftree name="mydocument" width="350" height="400">
       
            <cfoutput query="qfolder" group="element1" >
                <cftreeitem parent="mydocument" value="#element1#" expand="yes" >
               
                <cfoutput group="element2">
                    <cfif element2 neq "">
                        <cftreeitem parent="#element1#" value="#element2#"  expand="no" >
                    </cfif>
                </cfoutput>
               
                <cfoutput group="element3">
                    <cfif element3 neq "">
                        <cftreeitem parent="#element2#" value="#element3#"  expand="no" >
                    </cfif>
                </cfoutput>
              
                <cfoutput group="element4">
                    <cfif element4 neq "">
                        <cftreeitem parent="#element3#" value="#element4#"  expand="no" >
                    </cfif>
                </cfoutput>
               
                <cfoutput group="element5">
                    <cfif element5 neq "">
                        <cftreeitem parent="#element4#" value="#element5#"  expand="no" >
                    </cfif>
                </cfoutput>
               
                <cfoutput group="element6">
                    <cfif element6 neq "">
                        <cftreeitem parent="#element5#" value="#element6#"  expand="no" >
                    </cfif>
                </cfoutput>
               
            </cfoutput>
        </cftree>
    </cfform>

    The result

adexfe

  • Visit adexfe's Xanga Site
    • Name: Michael Abiodun
    • Metro:
    • Member Since: 4/4/2008

Weblog Archives

Don't worry - your calendar is here… to see it in action just click "Save" above and refresh the page.