Intro To Data

The whole focus of this class is leading up to integrating databases with a web site. We've looked at how the front end languages display the layout, colors and receives the content. We've looked at how the database stores data which can be accessed by the controller level. No matter what the language, there needs to be a connection between the server side script server and the database server. Each language creates this connection in its own way. BoxLang does it by having the server manage "datasources". Each datasource stores the location, username, password and database name in the BoxLang server so that when we are writing code, we can simply reference that datasource without having to put the username and password embedded in the source code. There are plusses and minuses with that approach but it does make thing easier for us as programmers.

Note: Before continuing, please follow these directions:

1.Open your IDE and navigate to your repo folder 1.Open the file called Application.bx 1.Near the top of the page will be the line this.dsource = '';. Change that to be your username for this class. (i.e. this.dsource = 'DanCard';) 1.Also in the Application.bx, in the function onApplicationStart() you will see the line application.dsource = dsource. Chnage this to be application.dsource = 'yourUserName' ( but type in your actual username ) 1.Open the file .env. Made the line PPWD= the password you got from me at the beginning of the semester. 1.Use CommandBox to navigate to the root of your local site and restart the server ( server restart). 1.Everyone in the class has a unique datasource which points to their database. For example, BoxLang has a tag called bx:dbinfo which allows us to connect to the database and see some of the its contents. In this case, it is set up to use your personal datasource. It matches your login name.

Lesson 11 of 12 - Learn BoxLang