failedToEnableSharding() 공개 정적인 메소드

public static failedToEnableSharding ( string $dbName, string $errorMessage ) : MongoDBException
$dbName string
$errorMessage string
리턴 MongoDBException
예제 #1
0
 /**
  * Enable sharding for database which contains documents with given name.
  *
  * @param string $documentName
  *
  * @throws MongoDBException
  */
 public function enableShardingForDbByDocumentName($documentName)
 {
     $dbName = $this->dm->getDocumentDatabase($documentName)->getName();
     $adminDb = $this->dm->getConnection()->selectDatabase('admin');
     $result = $adminDb->command(array('enableSharding' => $dbName));
     if ($result['ok'] != 1 && $result['errmsg'] !== 'already enabled') {
         throw MongoDBException::failedToEnableSharding($dbName, $result['errmsg']);
     }
 }
예제 #2
0
 /**
  * Enable sharding for database which contains documents with given name.
  *
  * @param string $documentName
  *
  * @throws MongoDBException
  */
 public function enableShardingForDbByDocumentName($documentName)
 {
     $dbName = $this->dm->getDocumentDatabase($documentName)->getName();
     $adminDb = $this->dm->getConnection()->selectDatabase('admin');
     $result = $adminDb->command(array('enableSharding' => $dbName));
     // Error code is only available with MongoDB 3.2. MongoDB 3.0 only returns a message
     // Thus, check code if it exists and fall back on error message
     if ($result['ok'] == 1 || isset($result['code']) && $result['code'] == 23 || $result['errmsg'] == 'already enabled') {
         return;
     }
     throw MongoDBException::failedToEnableSharding($dbName, $result['errmsg']);
 }