Find Mongo Document By ID Using The PHP Library

My new job as a Developer Advocate with IBM means I get to play with databases for a living (this is the most awesome thing ever invented, seriously). On my travels, I spent some time with MongoDB which is a document database – but I ran into an issue with fetching a record by ID so here’s the code I eventually arrived at, so I can refer to it later and if anyone else needs it hopefully they will find it too. Continue reading

Installing XHGui

There’s a new version of XHGui (well, a few months old) and it’s fabulous! It’s got a few new dependencies though so I thought I’d write down how I set up my version, in case it’s helpful to anyone else (and so I feel like a pro next time I have to do this!). If you’re not familiar with XHGui it’s a fabulously easy and friendly way to profile your application; to understand which method calls in a page take the time and how many times they are made, so you can improve the performance of your application. All these instructions are for my 32-bit Ubuntu 12.10 system, hopefully they will work for you or you’ll be able to adapt them as appropriate.

Dependencies

XHGui needs version numbers or fluffy animal names, because this is a really major release and quite different to what went before in both technology and in looks. In particular, it now uses MongoDB. If you’re not familiar with MongoDB, it’s a super-friendly NoSQL database that makes a really handy backend for this kind of unstructured data – because every run of every page will look different. Therefore you will need:

  • MongoDB itself
  • The pecl extension for mongo
  • The xhprof pecl extension (read on if you’re using PHP 5.4, there’s a gotcha)

Continue reading

Book Review: MongoDB and PHP

Despite having been toying with MongoDB and PHP for quite a while, I’ve only just picked up and read the “MongoDB and PHP” by Steve Francia, published by O’Reilly (disclaimer: I’ve collaborated with Steve on a few articles and he sent me a copy of the book to read)

Continue reading

Importing and Exporting MongoDB Databases

I’m enjoying working with MongoDB but as with any new technology, it can take a little while to find your way around all the tools related to that stack. In particular, I found myself wondering how do I mysqldump for mongodb?

It should have come as no surprise that the command I wanted was called mongodump, really! Continue reading

Simple CRUD with MongoDB

When I meet a new technology, I like to experience it “just as it comes”. I’m happy at the command line and I like to type actual commands and see man pages before I use any wrappers or helper tools. So when I met MongoDB for the first time, I did exactly that. This post shows those first steps of creating a database, and inserting, reading, deleting and updating data.
Continue reading