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 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
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: Advanced Data Handling
By: Brian Vaughn
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 6
    2005-08-03

    Table of Contents:
  • Data Management Made Easy Using Nennius: Advanced Data Handling
  • Advanced Application Configuration
  • Expanding Our Application Menu
  • Creating the User Comments Component
  • Creating Component Dependencies
  • Component Notes
  • Help Files
  • File Attachments

  • 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: Advanced Data Handling - Creating Component Dependencies


    (Page 5 of 8 )

    Now that we have created an association between our Comments component and the previously created News component, a potential problem presents itself. What happens if a user deletes a News entry which contains one or more Comment entries (attached)?

    Nennius offers a simple solution for this scenario as well. Simply update the following data found in the DB Field array in the News component file ('/components/news.php'):

    # 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

            )

           

            # setup dependency information to clean all associated comments as well upon deletion

            'db_dependency_tables'         => array(

                                                  array ( 'db_table_name'        => 'comments',

                                                         'db_field_name'        => 'news_id',

                                                          'db_display_name'      => 'Comment' )

                                                  ),

            'db_dependency_flush'          => TRUE

    );

    As you can see we've added two array keys to the 'id' descriptor array: 'db_dependency_tables' and 'db_depencency_flush'. The first, 'db_dependency_tables', contains an array of arrays - each array specifying information about a unique record dependency. Since only one dependency exists in our example application, only one array has been specified.

    The second variable, 'db_depencency_flush', contains a boolean value that tells Nennius how to act in the event that a News record (with one or more Comments records attached) is deleted. In our case we specified 'TRUE', which means that all associated Comments will also be deleted. (Note: If we had specified 'FALSE' then Nennius would have refused to delete any News releases with one or more User Comments attached.)

    More MySQL Articles
    More By Brian Vaughn


       · This is the third and final article in this series, and I thank all of you who have...
     

       

    MYSQL ARTICLES

    - MySQL Server Tuning Tips and Tricks
    - MySQL Query Optimizations and Schema Design
    - MySQL Benchmarking Tools and Utilities
    - MySQL Benchmarking Concepts and Strategies
    - 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





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