You are previewing MongoDB and PHP.
O'Reilly logo
MongoDB and PHP

Book Description

What would happen if you optimized a data store for the operations application developers actually use? You’d arrive at MongoDB, the reliable document-oriented database. Learn how to build elegant database applications with MongoDB and PHP. This book takes you through MongoDB basics such as queries, read-write operations, and administration, and then dives into MapReduce, sharding, and other advanced topics.

Table of Contents

  1. MongoDB and PHP
  2. Preface
    1. Conventions Used in This Book
    2. Using Code Examples
    3. Safari® Books Online
    4. How to Contact Us
  3. 1. Why Mongo?
    1. The Problem of Objects and Relational Data Structures
    2. The Problem with ORMs
      1. ORMs Are Hairy and Complex
      2. ORMs Aren’t Performant
      3. ORMs Neutered SQL
      4. Complicated Architecture
      5. PHP Is Mostly CRUD
    3. MongoDB, Optimized for Operation
      1. MongoDB Is a Document Database
      2. Document == Array
        1. Databases
        2. Collections
        3. Documents
      3. MongoDB Is Optimized for CRUD Operations
      4. Optimal Interface for Developers
      5. Optimal Performance
      6. Optimal Simplicity
      7. The Value of Consistency
  4. 2. PHP, MongoDB, and You
    1. Installing the Driver on Linux or MacOS X
      1. Checking for the Driver
      2. Installing the Driver
      3. Upgrading the Driver
    2. Installing the Driver on Windows
    3. Connecting to a Database
      1. Connecting to a MongoDB Database Server
      2. Selecting a Database
    4. The Basics (CRUD Operations)
      1. Creating/Selecting a Collection
      2. Creating a Document
        1. Important Details about Updating
        2. About Consistency
        3. About fsync
      3. Primary Keys and ObjectIds
        1. About Primary Keys
      4. Reading a Document
        1. About ObjectIds
        2. Retrieving Select Values
      5. Updating a Document
        1. Changing a Value
        2. Adding a Value
        3. Appending a Value to an Array
        4. Upsert and Multiple
      6. Saving a Document
      7. Deleting a Document
    5. The MongoDB Shell
      1. mongo
      2. Using the Shell
        1. Shell Is JavaScript
      3. Administrative Commands
    6. Working with Sets
      1. Querying Sets
      2. Finding (Querying) Data in MongoDB
      3. Pagination with the Cursor
      4. Ranges
      5. Working with Arrays
        1. Finding a Value in an Array
        2. $in
        3. $nin
        4. $all
        5. Matching Entire Arrays
        6. $slice
        7. $size
        8. $elemMatch
        9. Using Dot Notation
      6. Conditionals
      7. Working with Multiple Documents
        1. Updating Multiple Records
        2. Deleting Multiple Records
    7. Working with Indexes
      1. Setting Indexes
      2. Index Order
      3. About Indexes
      4. Compound Indexes
      5. Indexing Arrays
      6. Indexes and Memory
    8. Database References
      1. References Are Not Foreign Keys
      2. When to Use References or Reference versus Embed
      3. How to Create References
        1. Creating Manual References
        2. Creating DBRefs
      4. How to Access DBRefs
    9. Dates and Times
  5. 3. Advanced MongoDB
    1. Regular Expressions
      1. Creating a MongoDB Regular Expression
      2. Regular Expressions and Indexes
    2. Aggregation Commands
      1. The Distinct Command
      2. The Group Command
        1. Group Parameters
        2. Group Examples
      3. MapReduce
        1. Overview
    3. findAndModify
    4. GridFS
      1. What Is GridFS?
      2. Using GridFS
      3. Mongofiles
    5. Replication
      1. High Availability
      2. Why Three Nodes?
      3. Really Easy Configuration
      4. Checking the Replica Set Status
    6. Sharding
    7. Gotchas
      1. The $ Problem
      2. The Array != Array Problem
      3. Request Injection Attacks
  6. 4. PHP Libraries and Tools
    1. Object Document Mappers (ODM)
      1. Doctrine MongoDB ODM
      2. Active Mongo
      3. Mandango
    2. Tools
      1. MongoQueue
      2. Genghis
      3. RockMongo
    3. Frameworks
      1. Symfony2
      2. Lithium
      3. Zend
      4. Fuel
      5. FatFree Framework
  7. 5. Conclusion
  8. About the Author
  9. Copyright