OReilly MongoDB and PHP (2012).pdf

(7318 KB) Pobierz
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
842257222.009.png
842257222.010.png
MongoDB and PHP
Steve Francia
Beijing
Cambridge
Farnham
Köln
Sebastopol
Tokyo
842257222.011.png 842257222.012.png 842257222.001.png 842257222.002.png 842257222.003.png 842257222.004.png 842257222.005.png 842257222.006.png
 
MongoDB and PHP
by Steve Francia
Copyright © 2012 Steve Francia. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions
are also available for most titles ( http://my.safaribooksonline.com ) . For more information, contact our
corporate/institutional sales department: (800) 998-9938 or corporate@oreilly.com .
Editors: Mike Loukides and Shawn Wallace
Production Editor: Jasmine Perez
Copyeditor: Chet Chin
Proofreader: O’Reilly Production Services
Cover Designer: Karen Montgomery
Interior Designer: David Futato
Illustrator: Robert Romano
Revision History for the First Edition:
2012-01-24 First release
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of
O’Reilly Media, Inc. MongoDB and PHP and related trade dress are trademarks of O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and O’Reilly Media, Inc. was aware of a
trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and author assume
no responsibility for errors or omissions, or for damages resulting from the use of the information con-
tained herein.
ISBN: 978-1-449-31436-1
[LSI]
1327093111
Table of Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
1.
Why Mongo? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
The Problem of Objects and Relational Data Structures
1
The Problem with ORMs
2
ORMs Are Hairy and Complex
2
ORMs Aren’t Performant
2
ORMs Neutered SQL
2
Complicated Architecture
2
PHP Is Mostly CRUD
3
MongoDB, Optimized for Operation
3
MongoDB Is a Document Database
4
Document == Array
4
MongoDB Is Optimized for CRUD Operations
5
Optimal Interface for Developers
6
Optimal Performance
6
Optimal Simplicity
6
The Value of Consistency
6
2.
PHP, MongoDB, and You . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Installing the Driver on Linux or MacOS X
9
Checking for the Driver
9
Installing the Driver
9
Upgrading the Driver
10
Installing the Driver on Windows
10
Connecting to a Database
11
Connecting to a MongoDB Database Server
11
Selecting a Database
11
The Basics (CRUD Operations)
11
Creating/Selecting a Collection
12
Creating a Document
12
iii
842257222.007.png 842257222.008.png
Zgłoś jeśli naruszono regulamin