當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DocumentManager::getDatabase方法代碼示例

本文整理匯總了PHP中DocumentManager::getDatabase方法的典型用法代碼示例。如果您正苦於以下問題:PHP DocumentManager::getDatabase方法的具體用法?PHP DocumentManager::getDatabase怎麽用?PHP DocumentManager::getDatabase使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DocumentManager的用法示例。


在下文中一共展示了DocumentManager::getDatabase方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setUp

 public function setUp()
 {
     $this->type = 'Doctrine\\Tests\\ODM\\CouchDB\\Functional\\Article';
     $this->dm = $this->createDocumentManager();
     $database = $this->dm->getDatabase();
     $httpClient = $this->dm->getHttpClient();
     $httpClient->request('DELETE', '/' . $database);
     $resp = $httpClient->request('PUT', '/' . $database);
     $this->assertEquals(201, $resp->status);
     $data = json_encode(array('_id' => "1", 'title' => 'foo', 'body' => 'bar', 'type' => $this->type));
     $resp = $httpClient->request('PUT', '/' . $database . '/1', $data);
     $this->assertEquals(201, $resp->status);
     $cmf = $this->dm->getClassMetadataFactory();
     $metadata = new \Doctrine\ODM\CouchDB\Mapping\ClassMetadata($this->type);
     $metadata->mapField(array('fieldName' => 'id', 'id' => true));
     $metadata->mapField(array('fieldName' => 'title', 'type' => 'string'));
     $metadata->mapField(array('fieldName' => 'body', 'type' => 'string'));
     $metadata->idGenerator = \Doctrine\ODM\CouchDB\Mapping\ClassMetadata::IDGENERATOR_UUID;
     $cmf->setMetadataFor($this->type, $metadata);
 }
開發者ID:hlubek,項目名稱:couchdb-odm,代碼行數:20,代碼來源:ProxyTest.php

示例2: testKeepTrackOfUnmappedData

 public function testKeepTrackOfUnmappedData()
 {
     $httpClient = $this->dm->getHttpClient();
     $data = array('_id' => "2", 'username' => 'beberlei', 'email' => 'kontakt@beberlei.de', 'address' => array('city' => 'Bonn', 'country' => 'DE'), 'type' => str_replace("\\", ".", $this->type));
     $resp = $httpClient->request('PUT', '/' . $this->dm->getDatabase() . '/2', json_encode($data));
     $this->assertEquals(201, $resp->status);
     $user = $this->dm->find($this->type, 2);
     $this->assertInstanceOf($this->type, $user);
     $this->assertEquals('beberlei', $user->username);
     $user->username = 'beberlei2';
     $this->dm->flush();
     $resp = $httpClient->request('GET', '/' . $this->dm->getDatabase() . '/2');
     $this->assertEquals(200, $resp->status);
     $data['username'] = 'beberlei2';
     ksort($resp->body);
     ksort($data);
     unset($resp->body['_rev']);
     $this->assertEquals($data, $resp->body);
 }
開發者ID:doctrine,項目名稱:couchdb-odm,代碼行數:19,代碼來源:BasicCrudTest.php


注:本文中的DocumentManager::getDatabase方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。