Archive for September, 2008

CodeIgniter PHP Framework

Tuesday, September 30th, 2008

Ever since I have been developing and programming websites, I have tried to be as proficient and use the best practises that I can. I have got increasingly frustrated with inline SQL statements and spaghetti code. This prevents the idea of code reuse, which I have always strived for. What could be better than being able to reuse your code in different projects?

I have talked to a number of developers, and the suggestion I have got for these problems is to use Object-Orientated PHP, or use a PHP framework. These 2 things can be a bit hard for new programmers to understand, and frankly I don’t have them mastered either. I still don’t use PHP frameworks often, but I think I might have found one that could change that. The framework I am talking about is CodeIgniter.

CodeIgniter is a SMALL, and LIGHTWEIGHT framework unlike the majority of other PHP frameworks I have dabbled in. CakePHP and Symfony are huge frameworks that contain more functionality but have a big learning curve. Symfony even requires you to have access to a command line. This is a huge drawback as a number of web hosts don’t allow access to a command line for security reasons.

CodeIgniter has great documentation and screencasts that can really help you learn how to use it. It uses the MVC design pattern. MVC stands for Model, View, Controller and helps eliminate some of that spaghetti code and inline SQL statements I was talking about early. CodeIgniter is formed in such a way that it is extremely flexible and allows you to incorporate your own programming with ease. It allows expansion with libraries, plugins, and helpers.

Now to give you a taste for some code as to how easy it is to use CodeIgniter.

$data[‘title’] = ‘My CodeIgniter Tutorial’;
$data[‘intro’] = ‘Read my tutorial – or else’;
$this->load->view(‘mainpage’, $data)

How this works is that you are passing the $data variable to the view. CodeIgniter helps you by extracting the array keys into variables automatically. Now you can use $title and $intro in your view. You can see already how this will help to separate your business logic from your presentation markup.

Wait, static information is great and all but how do we access the database using CodeIgniter. CodeIgniter uses a pattern called Active Record. This makes handling databases a real brease! Below is an example.

$this->load->library(‘database’); // connect to the database
$data[‘query’] = $this->database->get(‘products’); // get all rows from the products table
$this->load->view(‘mainpage’, $data);

Now in the view you can do this:

while( $row = $query->result() ) :
<h1>$row->productName</h1>
<p>$row->productDescription</p>
endwhile;

If you wish to add a where clause to your query you can do something like this:

$this->database->where(‘productID’, 4);
$data[‘query’] = $this->database->get(‘products’);

CodeIgniter Blog Tutorial (20 mins)

If you want more examples, please visit the documentation. I would definitely suggest that you try this great framework out. Download CodeIgniter here, and let me know what you think!

Tags:
Posted in Web Programming | 8 Comments »

My WordPress Blog

Tuesday, September 30th, 2008

As you may have noticed, I have spend a bit of time redesigning and retooling my blog.

I have decided to hook on to a well known software called WordPress.  It makes posting and maintaining a blog easy.  The previous version of this blog was created on my own and decided that reinventing the wheel was not such a good idea.

I would recommend this software to anyone who wants a fully-customizable blog without the limitations of BlogSpot and other free hosts out there.  It takes a bit of getting used to but It is worth it in the long haul.

Below I have listed a few WordPress files and their purpose to get those of you interested a bit of a start.

Required Files
index.php – controls the functionality of your blog
style.css – contains all the styles that make your blog pretty to the human eye

Optional Files
single.php – the template when a single blog post is shown
author.php – the template when a particular authors articles are shown
header.php – the header of all files within the site – called in files by the function get_header()
footer.php – works similar as header

This is just a little taste of the file structure of a WordPress blog.  If this is a topic that interests you please leave a comment, and I will take that as a vote for more future posts on this issue.

Tags:
Posted in Software | 1 Comment »

Stay Productive!!!!

Monday, September 8th, 2008

Have you ever had a boss tell you to get back to work? Or told you to juggle multiple tasks while meeting deadlines?

I’m sure most of you have heard this at one point or another. I myself don’t have a boss looking over my shoulder making sure that I’m on task. This is a great part of being self-employed, but on the other hand puts a lot of responsibility on you.

As you know, especially in the web development business there can be a lot of distractions that in the end cost you time, and eventually money. How about those time-wasters such as Facebook, YouTube, and MSN?

How in the world can we ever stay on task???! And then consider that you can stay on task, how do you prioritize the piles of emails and tasks you get every day? Manage each tasks particular deadline, making sure that none are missed.

Now that I have enlightened you on this matter, I’m sure you can see how there is a title “Project Management” all by itself. Below I suggest some useful tools and techniques to help you become successful.

First of all, some sort of time tracker / project management software is of great help. It can keep track of your time, help estimate cost, and keep your projects on track.

A long with this, a business style email program can help you manage your tasks and emails in a productive manner. I personally use Microsoft Outlook 2007. It allows me to flag items due today, late this week, or next week. I can then quickly flag emails appropriately and focus on the items that are of greatest importance

There are plenty of things out there, and you just need to find out what helps you out. I hope this article makes you a more productive web developer.

Posted in Uncategorized | No Comments »

 
connect with me!