Home arrow MySQL arrow Page 4 - Case Study: Handling MySQL Growth With a PHP Class
MYSQL

Case Study: Handling MySQL Growth With a PHP Class


Sick of updating your MySQL database to add new fields half way through a project? In this article Bjorn discusses his PHP class that you can use to make changes to your MySQL database on the fly!

Author Info:
By: Bjorn Roysland
Rating: 4 stars4 stars4 stars4 stars4 stars / 12
November 12, 2002
TABLE OF CONTENTS:
  1. · Case Study: Handling MySQL Growth With a PHP Class
  2. · Generic MySQL Tables
  3. · The Tricky Part
  4. · Formmode
  5. · Conclusion

print this article
SEARCH DEVARTICLES

Case Study: Handling MySQL Growth With a PHP Class - Formmode
(Page 4 of 5 )

What is the class variable called $formmode? Well, let's say that you want the field published to be a checkbox in your form. The tricky part is to check if the field is check or not checked, especially with the save() function we use in this object.

To solve this, I added another method to WSDynamicObject called addFormModeField;

function addFormModeField( $fieldname, $behaviour ) {
$this->formmode[] = array($fieldname, $behaviour);
}


Although the naming of the function could have been better, the functionality works, and the method is used like this from the WSDocument class:

// Form Mode Behaviour
$this->addFormModeField("published","checkbox");


This simply says that the field published should be treated as a checkbox, so when we add a form to create or update an instance of WSDocument, we call the method:

$myobj->formMode();

The function formMode() runs through the array formmode, and set the value to checked if the value is 1 and sets it blank if the value is 0. When the object is saved, the reversed action makes sure that checked = 1 in your MySQL table.
blog comments powered by Disqus
MYSQL ARTICLES

- MySQL and BLOBs
- Two Lessons in ASP and MySQL
- Lord Of The Strings Part 2
- Lord Of The Strings Part 1
- Importing Data into MySQL with Navicat
- Building a Sustainable Web Site
- Creating An Online Photo Album with PHP and ...
- Creating An Online Photo Album with PHP and ...
- PhpED 3.2 More Features Than You Can Poke ...
- Creating An Online Photo Album with PHP and ...
- Creating An Online Photo Album with PHP and ...
- Security and Sessions in PHP
- Setup Your Personal Reminder System Using PHP
- Create a IP-Country Database Using PERL and ...
- Developing a Dynamic Document Search in PHP ...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials