Home arrow MySQL arrow 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.

  1. Data Management Made Easy Using Nennius: Creating a Web Application
  2. Configuring a Web Application and Defining Its Menu
  3. Creating SQL Tables
  4. Creating a Nennius Component, Defining the Entry-Point, and the Descriptor File
  5. The Component File
By: Brian Vaughn
Rating: starstarstarstarstar / 10
July 27, 2005

print this article



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:

# 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;
               # define primary key attribute for news table
               $f_db_info_array['id'] = (
                       array (
                               'db_field_name'        => 'id',
                               'db_field_type'        => 'int',
                               'db_field_length'      => 3,
                               'db_primary_key'       => TRUE,
                               # field is hidden from visibility at all times
                               'hidden_all'           => TRUE
               # date & time when article was initially posted / releasesd
               $f_db_info_array['datetime'] = (
                       array (
                               'db_field_name'        => 'datetime',
                               'db_field_display'     => 'Date / Time',
                               'db_field_type'        => 'datetime',
                               'db_field_length'      => 19,
                               'db_field_required'    => TRUE,
                               # set default value to be current date & time

                               'update_default'       => date( 'Y-m-d H:i:s' ),
                               # set attribute to be searchable by min & max date range
                               'search_date_range'    => TRUE
               # title of news release
               $f_db_info_array['title'] = (
                       array (
                               'db_field_name'        => 'title',
                               'db_field_display'     => 'Title',
                               'db_field_type'        => 'char',
                               'db_field_length'      => 100,
                               # set field to be searchable using a partial-match criteria
                               'input_search_type'    => 'TEXT',
                               'search_partial'       => TRUE,
               # main body of article

               $f_db_info_array['body'] = (
                       array (
                               'db_field_name'        => 'body',
                               'db_field_display'     => 'Article',
                               'db_field_type'        => 'char',
                               # define size of textarea input
                               'input_update_type'    => 'TEXTAREA',
                               'input_update_rows'    => 10,

                               # 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).


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).

>>> More MySQL Articles          >>> More By Brian Vaughn

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Oracle Unveils MySQL 5.6
- MySQL Vulnerabilities Threaten Databases
- MySQL Cloud Options Expand with Google Cloud...
- MySQL 5.6 Prepped to Handle Demanding Web Use
- ScaleBase Service Virtualizes MySQL Databases
- Oracle Unveils MySQL Conversion Tools
- Akiban Opens Database Software for MySQL Use...
- Oracle Fixes MySQL Bug
- MySQL Databases Vulnerable to Password Hack
- MySQL: Overview of the ALTER TABLE Statement
- MySQL: How to Use the GRANT Statement
- MySQL: Creating, Listing, and Removing Datab...
- MySQL: Create, Show, and Describe Database T...
- MySQL Data and Table Types
- McAfee Releases Audit Plugin for MySQL Users

Developer Shed Affiliates


Dev Shed Tutorial Topics: