Home arrow PHP arrow Page 2 - Building a Blogger with the Code Igniter PHP Framework

Start building the blogger with two MySQL database tables - PHP

People love to communicate, which may be why one of the most popular web applications you can develop is a blogger. In this six-part series, you'll learn how to develop a blogging application using PHP and the Code Igniter framework. In this first article, we'll create the bare bones structure, with plenty of code samples to help you understand the process.

TABLE OF CONTENTS:
  1. Building a Blogger with the Code Igniter PHP Framework
  2. Start building the blogger with two MySQL database tables
  3. Building a blog controller class to display blog entries
  4. Defining a simple view file
By: Alejandro Gervasio
Rating: starstarstarstarstar / 8
December 10, 2008

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement


Since the blog application that I plan to construct will store all of the blog entries and the respective comments on a couple of MySQL tables, the first step will consist of creating these tables.

In this case, the first of these database tables will be called "blogs," and its structure will look similar to this:



As shown above, the "blogs" database table comprises three basic fields: the corresponding ID, defined as the primary key; a title; and finally the text of the blog itself. In addition, you can see that it has already been populated with some trivial data, but this step is completely optional. So if you want to start building the blogger with an empty table, then go ahead and do it.


Now that I have defined the first "blogs" MySQL table, it's time to create another one, which will be used to store the comments about each blog entry. Sounds pretty logical, right? Therefore, here's the empty structure of this brand new table, which not surprisingly is called "blogs_comments." Take a look at it, please:



As you can see, the above table will be utilized for storing the comments on each blog entry. In this case, each comment submitted by a user will include the author and the corresponding text as well. In addition, you may have noticed that this table contains a "blog_id" field. This field will be utilized as a foreign key to link this table with the previous one.

So far, so good. At this stage, I have created two simple MySQL tables that will be employed by the blog application, first for displaying a group of existing blog entries, and then for posting different comments on each of them.

The next step involves defining a controller class. This class will initially be responsible for displaying all of the blog entries stored in the "blogs" MySQL table that you saw before.

The details of this process will be covered in the following section. Therefore, jump forward and read the next few lines.



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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- 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: