PHP
  Home arrow PHP arrow Page 3 - Building a Site Engine with PHP, Part 5
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
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? 
PHP

Building a Site Engine with PHP, Part 5
By: James Murray
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 32
    2004-07-19


    Table of Contents:
  • Building a Site Engine with PHP, Part 5
  • Plug it in, Plug it in!
  • All your Modules Belong to MySQL
  • Improve your Blocking Skills
  • Build your very own Theme Park!

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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


    Building a Site Engine with PHP, Part 5 - All your Modules Belong to MySQL
    ( Page 3 of 5 )

    Modules get loaded into the database just like the plug-ins do. In the database you have two tables -- modules and module_status:

    • The modules table contains the same things that the plugins table does (only for the modules instead of the plug-ins) with one slight difference -- we’ve dropped the priority field and added a field for plugin_ID.
    • The module_status table is just like the plugin_status table; it contains the mod_ID which corresponds to the mod_ID in the modules table and the mod_status field. The mod_status field is also one of two values, “initialized” or “not_initialized”. Just like the plug-ins, these values tell the module loader to either load the module or not to load it.

    When installing modules, start first with the modules table, put the module name in the mod_name field, and then put the directory that holds the modules in the mod_dir field. Once again this is the name of the directory that will hold the modules, beyond the plug-in directory. Then you need to fill in the mod_file with the name of the PHP file that makes up the module. Here’s a small example if you’ve forgotten the third article.

    Let’s say you have a module in the following directory,

    ROOT/plugins/foo_plugin/modules/bar.mod.php

    Then the mod_dir would be “modules” and the mod_file would be “bar”. The reason we want it to be like this instead of the way we did it with the plug-ins is because it makes it easier for us to make multiple modules that use the same plug-in.

    After you have the location set up, you’ll need to put in the plugin_ID of the plug-in that the module depends on. For example, if you have a plug-in named foo_plugin with a plugin_ID of 2, and the module bar.mod.php depends on foo_plugin to work. Then you’d put 2 in the plugin_ID field of the modules table for the bar.mod.php module. After that’s all done, you can fill in your optional fields which are mod_author, and mod_version, if you’d like.

    Now in the module_status table, once again we need to put in the mod_ID which is an auto incrementing field in the modules table and is generated when we install a new module. Then we need to set the mod_status to either initialized or not_initialized depending on if you want it to load or not.



     
     
    >>> More PHP Articles          >>> More By James Murray
     

       

    PHP ARTICLES

    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5
    - The Role of Interfaces in Applying the Depen...
    - Dependency Injection: Using a Setter Method ...
    - Using a Model Class with the Dependency Inje...
    - Injecting Objects Using Setter Methods with ...
    - Injecting Objects by Constructor with the De...
    - The Dependency Injection Design Pattern in P...
    - Performing Inferential Statistical Analysis ...
    - Performing Descriptive Statistical Analysis ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    Stay green...Green IT