[Admin Log In]

New Features in Phoenix MVC 0.2

Posted on Jan 7, 2011 in Projects

Phoenix MVC has been getting some improvements as I develop the first version of the site. A few bug fixes and a few new features round out the current changes to the framework. I hesitate to add more, but future plans are to allow everything to be fully customised via user-created plugins.

Read on to see the current list of changes.

Database

The database system now has support for "Count" queries. Internally, this converts SQL to "count(*)" queries and returns the result.

Column names are now escaped with `backticks` (which work in both MySQL and SQLite), to allow for column names like 'Order', or 'Group'.

Views

The smarty functions have been improved: Special characters in URL's (in forms and actlinks) are now encoded to increase compatibility and validity of outputted HTML. Forward slashes are not encoded, however.

Changes to form elements: The textarea and hidden functions have been added, which behave similar to the field function. The textarea and field functions have an additional class added to them when they are invalid, which by default highlights them red. Other classes have been added for validation errors, for easy CSS styling.

Validation

Validation has been improved upon and additional validators have been added. The Validate function in a validator now takes the model object, the field name, and the field value as arguments, rather than just the field value. This has allowed some additional validator functionality to be added easily.

db-unique: This validator will look in your database to check if this value is unique. Optionally, a list of fields to filter by can be specified (unique within a particular group), and the check can be made case-insensitive.

urlsafe: This validator is a simple extension of the regular expression validator, which will limit the characters in the value to alphanumeric characters, and the hyphen and underscore characters. Yes, it is overly limiting and this may change in the future.

Routing

The biggest new feature is the addition of custom routing. Custom routers can be implemented and added in the config file. By default, there is the "Skipping" router, which can be used to skip the action or the controller in a route, or both. There is also a "PageAction" router, which will allow the action to be skipped, and the rest of the parameters passed into a specified default action. This is great for dynamic pages, and an example can be seen right now in the (currently unfinished) project documentation pages.

CustomQuery

The last new feature is a custom query object, which simply executes some SQL and lets you read the results. It's basic, it's simple, and it's easy to use.

Bug Fixes

Besides the ones mentioned above, other bug fixes have been made in Authentication, Authorisation, Post, Model, Controller, and Router.

SVN Commit Log

Revision: 32
- Authentication fixed to properly support _Post routes
- Authorisation cookie deletes the cookie correctly
- Database, Model, and Query updated to allow Count queries, as well as backtick-escaped column names
- Form and ActLink updated to escape action URLs
- TextArea and Hidden field typed added
- Field and ValidationSummary adds a class to show validation errors
- Some changes to prevent Model incorrectly caching Get and Find results
- Post does proper null-checking to allow blank values to be bound
- Added CustomQuery class to execute arbitrary SQL
- Added action_name field to RouteParameters to correctly allow for _Post actions
- Added custom routing support, and custom routers: SkippingRouter and PageActionRouter
- Changes to validation to allow for more validators to be implemented.
- Added new validators: UrlSafeValidation, DbUniqueValidation

Posted on Jan 7, 2011 in Projects

Follow-Up Blogs

Comment on 'New Features in Phoenix MVC 0.2'