Codeigniter has the option to use a SQL database to store sessions. One of my projects however uses MongoDB. I didn’t want to have to run an instance of MySQL just for sessions so I modified the session libray for Codeigniter to use MongoDB instead. This is a first run at it and requires modifying one of Codeigniters core files and is not the best solution.
This modification assumes you have created a Mongo library for your Codeigniter application like the one from this post at Stack Overflow.
So you can access Mongo like - $this->mongo->db->findOne();
Once you have that working with your application, download the modified Session.php file here and place it in your ‘system/libraries’ folder overwriting the Session.php file which is already there.
iPhone 3GS on the left, iPhone 4 on the right.
Wow. Image snagged from the iPhone 4 review on Engadget.

iPhone 4 simply looks like an amazing device. It has just about everything on it that I want to fit into my pocket; phone, camera, HD video recording, mobile gaming and video conferencing. And finally allows for multitasking. The only issue that I have with the device now? It is still locked to one carrier.
With all the Not Only SQL (NoSQL) buzz going around I thought I would check out one of the many options available for a new project. After reading about a few I decided to check out MongoDB; a document-oriented DBMS. You can check it out here
MongoDB bridges the gap between key-value stores (which are fast and highly scalable) and traditional RDBMS systems (which provide rich queries and deep functionality).
Going from a relational database to a non-relational document database takes a bit of a mindset change when thinking about how to structure your data. The biggest issue I have ran into was how to store relations.
The answer? Just duplicate the data I need while using the MongoDB _id field to store a relation when needed for an update or link reference.
So lets say I have a table of comments in a SQL database. I would have a column in that table called “user_id” which would allow me to relate back to the user table to display who made a particular comment.

In MongoDB I will also have separate collections for comments and users. But within a comment object I would embed certain parts of the user object.

Now when I query for comments of a particular post I will have all the information I need to display the comment listing in one query. However, now the user data is duplicated and if the user updates their email we have to make sure to update all their entries in the comments collection as well.
There will be more to come as I work with Mongo and learn more about it.
A little over a month ago I was helping a colleague find resources for UI design for the iPhone. Since he doesn’t own one, I was trying to link him up to a design gallery. There are a billion and one…
365 Days of Food
#92 Bell’s Oberon (via JoeFoodie)
One of the first signs of summer in Michigan is finding 6 packs of Bell’s Oberon on store shelves. Like a sunny day, Oberon is light, golden, & refreshing. A quintessential wheat ale.
Comments