Last active
September 21, 2015 14:23
-
-
Save Stoffo/8d36dc550ac8e4b18be0 to your computer and use it in GitHub Desktop.
Check MongoDB Collection Existance
This file contains 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 | |
/** | |
* Checks if a Collection already exists. | |
* Returns true if Collection exists, otherwise it returns false. | |
* | |
* @param $collection | |
* | |
* @return bool | |
*/ | |
public function CollectionExists($collection) { | |
if ($this->db_handle->system->namespaces->findOne(["name" => $this->db.".".$collection]) === null) { | |
return false; | |
} else { | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment