The Value of Proper Hosting

October 03, 2008 at 1:47 pm

If you are at all serious about your site, you need proper hosting. This could be a "you get what you pay for" conversation, but I think it's more important to discuss the hidden factors, which many non-web professionals are likely unaware of.

Let's start with the basics. What is web hosting? Web hosting is a service, which provides you with disk space and a network connection on a web server on which to serve your site to the masses over the Internet. Most web hosting packages consist of space to store your website (including a database), as well as email service. Right off the bat you should be realizing that your choice of hosting providers influences two essential components of your business — your website and your email.

The obvious side effects of a poor hosting provider are that your website or your email could be inaccessible more often than with a good provider, but you don't need me to tell you that. What I'm going to talk about today are the less obvious side effects that you're not likely to think about.

  1. Poor hosting makes life miserable for your web developer. It really does and you should... Continue Reading

Counting Comments: Why I didn't use COUNT(*)

October 03, 2008 at 7:26 am

When developing this blog, one decision I had to make was how I wanted to retrieve the number of comments per post to be displayed on the blog index page. This is a specific example, but this is an issue that is raised in many web applications, whenever you need to display how many sub-elements there are per item (eg. threads per forum, replies per message, posts per category, etc.). It's also an example where conventional wisdom is wrong.

For the sake of this article, let's say our tables look like this:


posts
---------------
id INT
title VARCHAR
body TEXT

comments
---------------
id INT
post_id INT
comment TEXT


The obvious answer is to query the posts table for the post data, join the comments table and count the comments where the post_id matches. Well, that will get you your answer...eventually. Aggregate functions in MySQL, especially COUNT(*) work very well when you're only returning the COUNT(*) value, and when you're only querying one MyISAM table. If you're querying multiple tables, or using InnoDB tables then you will run into some pretty nasty performance issues. So, in this case, it's not the best approach.

"Well then,"... Continue Reading

New Blog Studio Site

October 02, 2008 at 1:48 pm

The new Blog Studio website is finally up and running! It's been several weeks of planning, designing, coding, refining, and filming, but now it's done. Woo hoo! Let me know what you think in the comments.

Clearing The DNS Cache in OS X

September 24, 2008 at 8:19 pm

On a fairly regular basis I need to clear my DNS cache when I move a site from one server to another for example. In the past, I always did this in terminal with lookupd -flushcache. However, today when I tried this I received a "command not found" error.

I don't know when it disappeared, as I seem to recall using it recently, but none the less, lookupd was gone. As it turns out, lookupd was replaced with dscacheutil. So, now when you want to flush your cache simply enter dscacheutil -flushcache in terminal and Bob's your uncle.

CodeIgniter insert_id and db_session

September 24, 2008 at 8:19 pm

This seems rather obvious in retrospect, but this morning I encountered and issue trying to return the id value of the last record I inserted on a CMS where the record was inserted properly, but the id returned by the insert_id() helper function was always 0.

The original code was:


if($this->db->insert('posts',$data)) {
    $this->db_session->set_flashdata('success','Post Added Successfully!');
    redirect('/posts/edit/'.$this->db->insert_id());
}

Seemed simple enough: try to insert a record, on success set the flash message, and redirect to the record I inserted for further editing.

Well duh. The application uses the database for sessions, which meant that setting the flash message used a database insert (with no id to be returned). Once I clued into that the solution was simple, just store the id before setting the flash message:


if($this->db->insert('posts',$data)) {
    $id = $this->db->insert_id();
    $this->db_session->set_flashdata('success','Post Added Successfully!');
    redirect('/posts/edit/'.$id);
}

Hardly mind blowing, but just an example of why you alway have to be conscience about what's going on in the background of these helper functions when using a framework.

Blog RSS Code RSS

Thody.Location

Toronto, Canada

Thody.Status

Thody.Tunes

The Dears – I Fell Deep
2 days, 4 hours ago