Last active
August 29, 2015 14:04
-
-
Save jamesBan/4f3412ad06092a0c1fee to your computer and use it in GitHub Desktop.
检查mongodb collection 是否存在
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $mongo = new MongoClient(); | |
| $db = $mongo->dbName; | |
| $collection = $db->collectionName; | |
| $cursor = $collection->find($criteria, array('_id' => 1))->limit(1); | |
| if($coursor->count() == 0){ | |
| exit('not exist'); | |
| } | |
| exit('exits'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment