HomeMySQL Page 5 - Data Management Made Easy Using Nennius: Creating a Web Application
The Component File - MySQL
Previously, we took a look at the Nennius engine and discussed several out-of-the-box features available to PHP developers. Now we are ready to create our own Nennius web application, and so we will discuss all of the steps necessary to do that.
As previously stated, the component file describes attributes of our data. It also contains any custom programming logic that a developer wishes to add on top of a Nennius application. (This will be discussed in greater detail in Part 3.) Our component file will contain the following:
<?php # basic news component class news extends nennius_component {
# store class-wide reference to control object # NOTE: this object is created by the nennius_component class, so the # main purpose of this var declaration is to make sure that the # developer is aware that the nennius_control class is accessible
var $nennius_control = NULL;
#--------------------------------------------------------------- # sets up necessary internal vars, creates new control object # and passes self-reference to it #--------------------------------------------------------------- function news( $p_component_descriptor_file ) {
# call out to constructor of parent class with descriptor file $this->nennius_component( $p_component_descriptor_file );
} # END news
#--------------------------------------------------------------- # retrieves and returns assoc. array containing db column info #---------------------------------------------------------------
function get_info_db_array() { $f_db_info_array = NULL;
# hide field from search & view modes 'hidden_search' => TRUE, 'hidden_view' => TRUE ) );
# after all attributes have been setup, return array return $f_db_info_array;
} # END get_info_db_array()
} # END news class ?>
As you can see, only two functions are required for our component class. One, the descriptor, simply defers to the nennius_component class (which in turn sets up and instantiates all necessary API classes). The other, get_info_db_array(), creates and returns an associative array describing our data's attributes. The array values listed above should be self-explanatory, but for a detailed list of all possible array keys and values please refer to the Nennius developer's documentation (http://nennius.sourceforge.net/dev_manual.php#custom_attributes).
Conclusion
We have now completed our example Nennius web application. To use the application, you simply need to direct your web browser to the 'index.php' file we defined above and enter your login information: 'admin' / 'admin'. As an alternative you may also access this application online at: http://nennius.sourceforge.net/nennius/webapps/news
Once you have logged in you will be able to pform standard data-management operations (such as add, modify, delete, search, sort, etc.) on the news releases data that you enter. For more information about how to pform these operations, please refer to the Nennius user's documentation (http://nennius.sourceforge.net/user_manual.php).
We will continue in Part 3 by expanding the scope of this application, and taking a look at some of the advanced features Nennius offers its developers. We will also look at creating other components and defining their relationship to the 'news' component we have already created. If you have any questions in the meanwhile, please feel free to visit the Nennius user forums (http://nennius.sourceforge.net/phpbb).