MySQL
  Home arrow MySQL arrow Page 5 - Data Management Made Easy Using Nenniu...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Moblin 
JMSL Numerical Library 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MYSQL

Data Management Made Easy Using Nennius: Creating a Web Application
By: Brian Vaughn
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 10
    2005-07-27

    Table of Contents:
  • Data Management Made Easy Using Nennius: Creating a Web Application
  • Configuring a Web Application and Defining Its Menu
  • Creating SQL Tables
  • Creating a Nennius Component, Defining the Entry-Point, and the Descriptor File
  • The Component File

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Data Management Made Easy Using Nennius: Creating a Web Application - The Component File


    (Page 5 of 5 )

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

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


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Again, thank you for reading through this article. I hope that part two of this...
     

       

    MYSQL ARTICLES

    - Take Some Load off MySQL with MemCached
    - MySQL Table Prefix Changer Tool in PHP
    - Using the SIGNAL Statement for Error Handling
    - Error Handling Examples
    - Error Handling
    - Completing a Search Engine with MySQL and PH...
    - Paginating Result Sets for a Search Engine B...
    - Building a Search Engine with MySQL and PHP 5
    - Using Boolean Operators for Full Text and Bo...
    - PHP, MySQL and the PEAR Database
    - Working with PHP and MySQL
    - Getting PHP to Talk to MySQL
    - Creating an RSS Reader: the Reader
    - MySQL Security Overview
    - Creating the Admin Script for a PHP/MySQL Bl...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway