MySQL
  Home arrow MySQL arrow Page 4 - 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 - Creating a Nennius Component, Defining the Entry-Point, and the Descriptor File


    (Page 4 of 5 )

    Creating a Nennius Component

    Now that we have setup our basic web application, it is time to consider the data we will be managing. Since our example application is intended only to manage news releases for a corporate website, our component will be relatively basic. There are a variety of ways to create Nennius components, some simple and some complex. All component logic can be contained within a single file, or split apart into multiple files. The latter is recommended in the Nennius documentation. So for our component we will split our logic into three files, each described below:

    /news/index.php                      - instantiates news component - this is our entry-point file
    /news/components/news.php    - contains all programming logic & describes DB structure
    /news/descriptors/news.php     - defines basic component info & threshold permissions

    At first, this may seem overly complicated. However it is a good development habit to design projects to be easily scalable. By splitting these three areas of logic into their own files, we will make upgrading and enhancing our system (described in Part 3 of this article) a much easier task. Furthermore, creating each file in its own descriptive folder area will result in a lot less clutter for larger Nennius projects.

    Defining the Entry-Point

    Since our application will only be managing one type of data, we have chosen to name our entry point 'index.php'. An entry-point file simply includes and instantiates our component class, so defining it will be relatively simple:

    <?php
    # define location of component & descriptor files
    $component_file        = 'components/news.php';
    $descriptor_file       = 'descriptors/news.php';

    # include parent nennius_component class
    include_once "../../nennius.component.php";
    include_once $component_file;

    # create a new object to kick things off

    # NOTE: New object will extend nennius_component class,
    #       so in order to instantiate it must be passed a descriptor file.
    #       optionally, we will also pass a reference to an external fields file,
    #       to better seperate our areas of logic

    new news( $descriptor_file );
    ?>

    As you can see, all our index file does is include our component file (along with the class it extends) and then instantiates it by passing it a reference to our descriptor file. Both the component and descriptor files have been mentioned briefly, but let's now take a closer look at each.

    The Descriptor File

    The descriptor file is where we store information pertaining to the component as a whole. This information ranges from the name of the component (displayed in the browser's title area) to the name of the DB table containing our component's data. This is different than the component file, as it does not describe the data's attributes, merely its overall behavior. Our descriptor file will contain the following:

    <?php
    # set   display name for component
    $GLOBALS['g_main_display_name']               = 'News Releases';

    # set primary db table name
    $GLOBALS['g_db_primary_table']        = 'news';

    # set primary key for main db table
    $GLOBALS['g_db_primary_table_key']    = 'id';

    # set (optional) primary display field for db table

    # NOTE: this field is used as the main display name for a record


    $GLOBALS['g_db_primary_table_name']   = 'title';

    # set required min. threshold for overall access

    # NOTE: this should be the same as the threshold specified in config.menu.php

    $GLOBALS['g_threshold_overall']               = $GLOBALS['ADMIN'];
    ?>

    More MySQL Articles
    More By Brian Vaughn


       · 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 3 hosted by Hostway