(HRTCVT)

Heads-Up Regarding the CodeIgniter Video Tutorial

August 23, 2008 @ 16:13:49

I’ve finally gotten around to working through the second video tutorial for CodeIgniter. It’s centered around creating a blog in about 20 minutes (it continues from the shorter, “Hello World” intro tutorial…so if you haven’t already, I’d start from there).

There’s a small error I didn’t notice (but should have). It had me stumped for a bit but, as is most always the case, the solution was painfully obvious.

I’ve got the video running and am coding along as the guy speaks. Pretty early on, when setting CodeIgniter to automatically connect to a particular database, you’re instructed to open system/application/config/autoload.php file to modify the $autoload['core'] array to include the database “core library”.

/*
| -------------------------------------------------------------------
|  Auto-load Core Libraries
| -------------------------------------------------------------------
|
| DEPRECATED:  Use $autoload['libraries'] above instead.
|
*/
$autoload['core'] = array('database');

A little later, after creating a couple of database entries and setting the page to display their values, I was greeted with the following error:

A PHP Error was encountered

Severity: Notice

Message: Undefined property: Blog::$db

Filename: controllers/blog.php

Line Number: 16

The call to $this->db->get failed because the $db member of Blog (which extends CodeIngiter’s Controller class) didn’t exist.

You know why? Did you actually read the comments in the php code above? I didn’t. I was quickly moving around and typing while the tutorial played. If you didn’t notice it the first time, reread them now.

See it? Nice and big and all-caps: DEPRECATED. “Use $autoload['libraries'] above instead.” Which I did and then it worked.

Lesson learned, right? Always read the comments.

6 Comments

Follow Comments