Home arrow PHP arrow Page 4 - Defining the Core Structure of a PHP Blogger

Defining the updateBlog() method - PHP

In the first part of this three-part series, we'll examine the basic outlines of creating a blog application with PHP 5. If you're currently working with PHP 4, this program can be adapted to that version of the language.

  1. Defining the Core Structure of a PHP Blogger
  2. Defining the blogger's core structure
  3. Defining the insertBlog() method
  4. Defining the updateBlog() method
  5. Defining the deleteBlog() method
By: Alejandro Gervasio
Rating: starstarstarstarstar / 11
November 21, 2006

print this article



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(){
            $this->mysql->query("UPDATE blogs SET
title='$title',author='$author',content='$content',date=TIMESTAMP(10) WHERE

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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: