PHP
  Home arrow PHP arrow Page 4 - Defining the Core Structure of a PHP Blogger
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

Defining the Core Structure of a PHP Blogger
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 11
    2006-11-21


    Table of Contents:
  • Defining the Core Structure of a PHP Blogger
  • Defining the blogger's core structure
  • Defining the insertBlog() method
  • Defining the updateBlog() method
  • Defining the deleteBlog() method

  • 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


    Defining the Core Structure of a PHP Blogger - Defining the updateBlog() method
    ( Page 4 of 5 )

    As I said in the previous section, the next step involved in creating the blog application relies on defining yet another handy method, aimed at updating an existing entry in the corresponding database table. This brand new method not surprisingly has been called "updateBlog()," and its definition is as follows:

    // update blog
    private function updateBlog(){
                $id=$this->blogData['id'];
                $title=$this->blogData['title'];
                $author=$this->blogData['author'];
                $content=$this->blogData['content'];
                $this->mysql->query("UPDATE blogs SET
    title='$title',author='$author',content='$content',date=TIMESTAMP(10) WHERE
    id='$id'");
                header('Location:'.$_SERVER['PHP_SELF']);
    }

    As shown above, the signature for the "updateBlog()" method looks nearly identical to the previous "insertBlog()" method. In this case, the only difference rests on the type of database operation that it performs, since it updates an existing blog entry instead of adding a new one.

    After a particular blog has been updated, the method reloads the main page where the complete set of blogs is conveniently displayed. Quite possibly, if you used to work on a frequent basis with DML operations, you'll find the prior method pretty simple to understand. What do you think?

    Well, at this point I provided you with a fairly decent explanation of how the previous "insertBlog()" and "updateBlog()" methods do their business. Therefore, it's time to examine the last method that I plan to include in the "BlogProcessor" class; in this case, I'm talking about the one called "deleteBlog()" and obviously it is responsible for removing a specified entry from the "blogs" database table.

    Curious about how this new method will be coded? Go ahead and read the following section.



     
     
    >>> More PHP Articles          >>> More By Alejandro Gervasio
     

       

    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 6 Hosted by Hostway
    Stay green...Green IT