Creating a Data Access Object
For our introduction into Data Access Objects, we'll create a small application to query, read, and update a database table containing information on users; this could be applied to a real-world example such as a login form, or a user management console.
We will be accessing the data from a table within our database, called tbl_Users
, which contains relatively basic information for each entry. Here, you can see a UML diagram of the User.cfc
bean, which has been created to reflect the columns and interact with the values from the table.
You can see from the UML diagram that we have a getter/accessor method for each property within the bean, and we also have a simple helper function, getFullName()
, which will concatenate the user's first and last names into a single string. We also have a public setter/mutator function for each property, although these haven't been included in this diagram for simplicity.
The User bean will play an incredibly important role used...