Category Archives: CodeIgniter

The more changes, the more stays the same!

It’s been a while, almost two years now, since my last post. Phew, let’s see how that happend (excuses, excuses..) and what’s happening in the future.

Pretty soon after my latest entry I went on a trip around the world for about 6 month and even though I fully intended to write weekly posts about cool stuff I did/encountered, I ended up not writing a single new entry. The trip was the best thing I’ve done in a long time though, so it definitely was worth it!

And once I got back, I was nearly overwhelmed by work. A lot of old projects needed maintenance and then a couple of big new projects came along and I simply lost sight and the interest in my blog. There was so much to do and so little time.

Now, two years later, I’ve re-discovered my interest for blogging/sharing and will try to do so on a more regular basis. Maybe actually do it once a week like I originally intended or at least a couple of times per month. They’ll probably not be the most extensive posts, but I’ll do what I can to keep them interesting.

So what’s going on right now/what has changed since my last post?

  • I’m still self-employed and working as a freelancer for serveral smaller companies/agencies. Even though I don’t need to be in any office or so and could easily work from any place I want to, I usually tend to stay at home and work from there. It’s what I’ve gotten used to and gives me the most flexibility in terms of working hours. I know there are quite a few people out there who can not work from home, because they get either easily distracted or want to keep work seperated from their private life. Both points I can understand, but so far it’s been working out fine for me…who knows for how long that’ll be the same :)
  • The site is at an all time high in terms of fake registration…
  • …and at a near all time low in terms of actual user activity. I guess I’ll have to spam some links on Twitter or so to get the traffic flowing again :)
  • I’ve switched from Prototype to jQuery. It’s been overdue for a long time and I’ve used the past year or so to get used to it and refine my skills. Absolutely loving it so far, so be prepared for a couple of jQuery related posts!
  • CodeIgniter 3.0 is still in beta/not released yet and it’s been like this for at least a year. I’m not sure what’s up with that, but I’m using it for all my current projects and it’s working like a charm.
  • I’m looking for a new PHP framework to base my projects on. CI has been fun, but I think it’s time to broaden my horizon and find something new/more advanced to play with. Laravel 4 looks really good, I think I’ll give it a try.
  • I’ve finally made the transition from SVN to Git. I have to admit I’m still not 100% sure about some things like branch management and such, but I’m getting there…I hope :) Most of my new projects are already hosted as private repos on Bitbucket and I want to start actually contributing to some open source software I’m using and give my own projects (mostly JS) a room for display. So keep an eye on my Github and Bitbucket profiles.
  • Inspired by some of the comments about my inital “Dev-Box” post, I’ve started experimenting with Virtual Box. Supposedly you can use the same VM on both Windows and Mac (which is important since I do work on both my MacBook and my Windows desktop machine and I want to share the development environment between them) and once I get the shared folder thing figured out, I’ll post a lengthy tutorial on how to get it all set up.

I think that’s it for now. Not too much after all, damn.

So here’s to more frequent updates on interesting topics! Cheers!

Extended logging of database errors in CodeIgniter

Some of you might and now and then have run into a database error while working with CI. Such errors are mostly caused by errors in your querys like not escaping user input or your fields or simply syntax errors.

In small applications that not much of a problem, but the bigger the application the harder it get’s to find the part where the bad query is hiding.

dootzky from the CodeIgniter Forum had exactly that problem and with a little help from wiredesignz we were able to add some more detail to the error messages!

Simply add this to the body of ‘application/errors/error_db.php’:

if($_SERVER['HTTP_HOST'] == 'localhost') {
   $trace = debug_backtrace();
   echo "The error occured in file ".$trace[4]['file']." on line ".$trace[4]['line']."";

Now additionally to the error you already know, you will be shown in which file and on which line the error occured (the db->get() method was called)! As this might pose a security risk on live systems, dootzky added the check for localhost.

I know that with CI 2.0 this might be obsolete because the error messages were enhanced, atleast the database errors now show filename and line, but someone still using some older version of CI (like I do for most of my older projects) might still find this handy.

P.S.: This is an older post I copied from my old blog. Thought some of you might find this useful.