From 2affc9affe712f670ffd79d3203ba3bb2299dff0 Mon Sep 17 00:00:00 2001 From: Kristina Chodorow Date: Fri, 6 Nov 2009 17:47:24 +0000 Subject: [PATCH] Exception msgs, Mongo descs, and gridfs example git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@290378 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/mongo/mongo/close.xml | 58 ++++++++++ reference/mongo/mongo/construct.xml | 26 +++++ reference/mongo/mongoconnectionexception.xml | 106 +++++++++++++++++++ reference/mongo/mongocursorexception.xml | 60 ++++++++++- reference/mongo/mongogridfs.xml | 30 +++++- 5 files changed, 278 insertions(+), 2 deletions(-) diff --git a/reference/mongo/mongo/close.xml b/reference/mongo/mongo/close.xml index 3dd8008182..237d5635bf 100644 --- a/reference/mongo/mongo/close.xml +++ b/reference/mongo/mongo/close.xml @@ -13,6 +13,64 @@ public booleanMongo::close + + This method does not need to be called, except in unusual + circumstances. The driver will cleanly close the database + connection when the Mongo object goes out of scope. + + + If you are using a service where objects do not go out of scope + between requests, you may wish to call close() at the end of + your program to keep old connections from hanging around. + However, it is probably more efficient to take advantage of + this fact and simply use a persistent connection, which will + automatically create a connection if needed and use it for as + many requests as the application server allows it to exist. + + + You may also wish to call close() if you are unsure of the + state of a connection and wish to guarantee a new connection will + happen. For example: + + + + +connect(); + +?> +]]> + + + + + vs. + + + + +close() +$mongo->connect(); + +?> +]]> + + diff --git a/reference/mongo/mongo/construct.xml b/reference/mongo/mongo/construct.xml index c10af45007..520114a2f6 100644 --- a/reference/mongo/mongo/construct.xml +++ b/reference/mongo/mongo/construct.xml @@ -16,6 +16,32 @@ booleanpersistent&false; booleanpaired&false; + + If you elect not to connect immediately, you will need to call + connect, persistConnect, + pairConnect, or + pairPersistConnect before doing any + database operations. + + + + +selectDB("foo")->command(array("distinct" => "bar", "key" => "age")); + +// okay +$mongo->connect(); +$mongo->selectDB("foo")->command(array("distinct" => "bar", "key" => "age")); + +?> +]]> + + diff --git a/reference/mongo/mongoconnectionexception.xml b/reference/mongo/mongoconnectionexception.xml index 8c1c73d0da..04c240957d 100644 --- a/reference/mongo/mongoconnectionexception.xml +++ b/reference/mongo/mongoconnectionexception.xml @@ -14,6 +14,112 @@ Thrown when the driver fails to connect to the database. + + + There are a number of possible error messages, to attempt + to help you diagnose the connection problem. These are: + + + + + + No server name given. + + + This error occurs if you pass in "" as the server name, + probably because of an typo with string interpolation, + e.g., "$servr" instead of "$server". + + + + + + failed to get left host [hostname] or port [portnum] + from [server]. + + + + + failed to get right host [hostname] or port [portnum] + from [server]. + + + + This indicated that the first or second server + respectively in a "server1,server2" connection string + was malformed. "[hostname]" and "[portnum]" will be as + much as the driver could dicipher of it. + + + + + + failed to get host [hostname] or port [portnum] + from [server]. + + + + This indicated that the server string was malformed. + "[hostname]" and "[portnum]" will be as much as the + driver could dicipher of it. + + + + + paired connection, but no right host given + + + The user attempted to create a paired connection but + passed a string that only listed one server to connect to. + + + + + Operation in progress + + + Connecting to the database timed out. + + + + + More links than your body has room for: N of M + + + N is the number of open connections and M is the + maximum number of connections allowed. By default, + the driver allows unlimited simultaneous connections + to the database. If you wish to limit them, you can set + mongo.max_connections and/or mongo.max_persistent (for + limiting perisistent connections). If you try to create + more than that number of connections, you will get this + error. + + + + + couldn't determine master + + + Neither server in a paired connection appeared to be master. + + + + + couldn't get host info for [server] + + + This indicated that DNS could not resolve the server address + you gave. This could easily be caused by a typo, for example, + "server" instead of "$server". + + + + + + If the error message is not listed above, it is probably an error + from the C socket, and you can search the web for its usual cause. + diff --git a/reference/mongo/mongocursorexception.xml b/reference/mongo/mongocursorexception.xml index 459d22fb28..82032912cb 100644 --- a/reference/mongo/mongocursorexception.xml +++ b/reference/mongo/mongocursorexception.xml @@ -12,8 +12,66 @@
&reftitle.intro; - Thrown by accessing a cursor incorrectly. + Caused by accessing a cursor incorrectly or a error receiving a reply. + + + If there is an error receiving a reply, there will be a more + specific error message to help diagnose the problem: + + + + + + could not establish db connection + + + A database reply could not be recieved because a connection + with the database could not be established. + + + + + no db response + + + This may not even be an error, for example, the database + command "shutdown" returns no response. However, if you + were expecting a response, this means the database didn't + give one. + + + + + bad response length: %d, max: %d, did the db assert? + + + This means that the database said that its response was + greater than 4Mb or less than 0. Generally, a number + greater than 5Mb should be reported to the developers as a + potential database bug (max response length is 4Mb). A + response of less than 0 often means a database assertion + occured. + + + + + incomplete response + + + Occurs if the database response is malformed. + + + + + [WSA ]error getting database response: errstr + + + "errstr" is an io error reported directly from the C socket + subsystem. On Windows, is prefixed with "WSA". + + +
diff --git a/reference/mongo/mongogridfs.xml b/reference/mongo/mongogridfs.xml index 0e28615310..1f2e77aa24 100644 --- a/reference/mongo/mongogridfs.xml +++ b/reference/mongo/mongogridfs.xml @@ -12,8 +12,36 @@
&reftitle.intro; - Utilities for storing and retrieving files from the database. + Utilities for storing and retrieving files from the database. + + + MongoGridFS extends + MongoCollection, so any of the methods + in MongoCollection can be used to + manipulate metadata. For example: + + + + +storeFile("game.tgz"); +$game = $grid->findOne(); + +// add a downloads counter +$game->file['downloads'] = 0; +$grid->save($game->file); + +// increment the counter +$grid->update(array("_id" => $id), array('$inc' => array("downloads" => 1))); + +?> +]]> + +