PHP: All content tagged as PHP in NoSQL databases and polyglot persistence
Earlier this summer, we kicked off a series on MongoDB where the goal was to write a simple todo application using native MongoDB drivers and three of our favorite scripting languages.
Till Klampaeckel has published a ☞ 3 part introduction to CouchDB for PHP developers.
This is part three of a beginner series for people with a MySQL/PHP background. Apologies for the delay, this blog entry has been in draft since the 13th December of last year (2009).
While the guide is pretty good, I’m not sure why MySQL or relational databases are mentioned in the title as the references/parallels are quite rare. If you are looking for more resources on CouchDB and PHP you should also try CouchDB basics for PHP developers and Quick Guide to CouchDB and PHP.
MongoDB strikes a balance between the familiarity and ease of use of MySQL, and the freeness and performance offered by document storage databases. The database has no set schema so you can add, remove and modify the structure of your documents without having to issue an UPDATE statement.
- installation on Windows
- a MongoDB wrapper
- using the MongoDB wrapper for basic CRUD operations
With document-oriented databases this is not the case. You just create a database and start developing. Every time you need to save some data, you just create a document, add the fields you need (for a shopping card you’d probably save a user_id, date, price, all the items, …) and save it to the database.
- installation on Mac OS X
- basic CRUD operations
Nowadays there is a new kind of databases that is getting very popular, specially for Web development, including the PHP world, which are the NoSQL databases.
This article focus specifically on MongoDB, despite there are several other NoSQL database implementations.
- basic intro to MongoDB
- basic CRUD operations
- an intro on MongoDB indexes
- storing files in MongoDB
- short Map-Reduce example
A tip on how to check file removal worked as expected:
Yes, you already figured out it’s as simple as
$grid->remove(). Here is something to keep in mind.
MongoGridFS::removewon’t present you with a message if it failed. To ensure that a file was successfully removed use
So I’ve decided that I want to properly document my MongoDB exploration and I may as well help others to learn with me. […] What I’m going to do here in part 1 is install MongoDB, install the PECL PHP extension and just play around a bit.
- installation on Ubuntu
- installation of MongoDB PECL extension
- basic blog sample application
I originally intended to sit down and start writing a Mongo datasource only to find that Yasushi Ichikaway had totally beat me to it, and written a great datasource. So instead, I’ll write about how you can get up and running with MongoDB.
A very basic example.
To do some prototyping, I wanted to load all 32k of our Drupal nodes into MongoDB. At first, the thought of doing this seemed daunting. Then I realized that with Drush I could use a very simple script to perform an entire migration. The result: With a 14 line PHP script, I transferred all of the nodes (CCK, taxonomy, and all) without a glitch.
I bet there are more such resources about MongoDB and PHP, but I hope these are will be a good start for every PHP programmer interested in MongoDB.
Disclaimer: I am not very familiar with the PHP development so the above articles were picked based on Twitter reactions.