当前位置: 首页>>代码示例>>PHP>>正文


PHP Document::set方法代码示例

本文整理汇总了PHP中Document::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Document::set方法的具体用法?PHP Document::set怎么用?PHP Document::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Document的用法示例。


在下文中一共展示了Document::set方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: new_vertex

function new_vertex($documents, $id, $nv)
{
    $v = new Document();
    $v->set("name", $id + 1);
    $v->set("component", $id);
    $v->set("distance", -1);
    $v->set("pr", 1.0 / $nv);
    $documents->add("vertices", $v);
    return $v->getHandle();
}
开发者ID:Auguraculums,项目名称:graphdb-testing,代码行数:10,代码来源:test.php

示例2: save

 function save(&$data)
 {
     $repo = $this->requireRepository();
     $user = $this->getConnectedUser();
     $this->data['Document']['repository_id'] = $repo['Repository']['id'];
     $this->data['Document']['user_id'] = $user['User']['id'];
     $this->data['Document']['kit_id'] = $repo['Repository']['kit_id'];
     $this->Document->set($this->data);
     // errors
     if (empty($this->data['Document']['tags'])) {
         $this->Session->setFlash('You must include at least one tag');
     } else {
         if (!$this->Document->validates()) {
             $errors = $this->Document->invalidFields();
             $this->Session->setFlash($errors, 'flash_errors');
         } else {
             if (!$this->Document->saveWithTags($this->data)) {
                 $this->Session->setFlash('There was an error trying to save the document. Please try again later');
             } else {
                 $this->Session->setFlash('Document saved successfuly');
                 $this->_clean_session();
                 $this->redirect(array('controller' => 'repositories', 'action' => 'index', $repo['Repository']['url']));
             }
         }
     }
 }
开发者ID:rmeruane,项目名称:repositorium,代码行数:26,代码来源:documents_controller.php

示例3: setView

 public function setView($view_name, $map_reduce_ar)
 {
     if (!isset($this->data['views'])) {
         $this->data['views'] = array();
     }
     $views = $this->data['views'];
     $views[$view_name] = $map_reduce_ar;
     parent::set('views', $views);
 }
开发者ID:servicehome,项目名称:PHP-CouchDB,代码行数:9,代码来源:View.php

示例4: create

 public function create()
 {
     $d = new Document();
     /* loop variables and set to Document */
     foreach ($this->post as $key => $value) {
         $d->set($key, $value);
     }
     /* save document in collection */
     $id = $this->documentHandler->save(COLLECTION_NAME, $d);
     echo json_encode(["result" => $id]);
 }
开发者ID:vinigomescunha,项目名称:ArangoDB-Ajax-PHP-Example,代码行数:11,代码来源:ArangoDB.class.php

示例5: testCreateDocumentWithInvalidKeys

 /**
  * Try to create a document with invalid keys
  */
 public function testCreateDocumentWithInvalidKeys()
 {
     $connection = $this->connection;
     $collection = $this->collection;
     $documentHandler = new DocumentHandler($connection);
     $keys = array("", " ", " bar", "bar ", "/", "?", "abcdef gh", "abcxde&", "mötörhead", "this-key-will-be-too-long-to-be-processed-successfully-would-you-agree-with-me-sure-you-will-because-there-is-a-limit-of-254-characters-per-key-which-this-string-will-not-conform-to-if-you-are-still-reading-this-you-should-probably-do-something-else-right-now-REALLY", "#", "|", "ü", "~", "<>", "µµ");
     foreach ($keys as $key) {
         $document = new Document();
         $document->someAttribute = 'someValue';
         $caught = false;
         try {
             $document->set('_key', $key);
         } catch (\triagens\ArangoDb\ClientException $exception) {
             $caught = true;
         }
         $this->assertTrue($caught, "expecting exception to be thrown for key " . $key);
     }
 }
开发者ID:vinigomescunha,项目名称:ArangoDB-Ajax-PHP-Example,代码行数:21,代码来源:DocumentBasicTest.php

示例6: testLasttWithCountAndTHreeDocuments

 /**
  * Test getting the last documents in a collection
  */
 public function testLasttWithCountAndTHreeDocuments()
 {
     // set up collections and documents
     $collectionHandler = $this->collectionHandler;
     $documentHandler = $this->documentHandler;
     $collection = Collection::createFromArray(array('name' => 'ArangoDB_PHP_TestSuite_TestCollection_Any'));
     $collectionHandler->add($collection);
     $document1 = new Document();
     $document1->set('message', 'message1');
     $documentHandler->save($collection->getId(), $document1);
     $document2 = new Document();
     $document2->set('message', 'message2');
     $documentHandler->save($collection->getId(), $document2);
     $document3 = new Document();
     $document3->set('message', 'message3');
     $documentHandler->save($collection->getId(), $document3);
     //Now, let's try to query any document
     $documents = $collectionHandler->last($collection->getName(), 2);
     $this->assertTrue(count($documents) == 2);
     //Let's try another random document
     $documents = $collectionHandler->last($collection->getName());
     $this->assertTrue(count($documents) == 1);
     $collectionHandler->delete($collection->getName());
 }
开发者ID:vinigomescunha,项目名称:ArangoDB-Ajax-PHP-Example,代码行数:27,代码来源:CollectionExtendedTest.php

示例7: set

 public function set($value)
 {
     $this->document->set($this->var, $value);
 }
开发者ID:jivoo,项目名称:jivoo,代码行数:4,代码来源:DocumentVar.php

示例8: Document

<?php

require_once 'lib/db.php';
require_once 'lib/template.php';
$doc = new Document('base');
$doc->title = "Banned";
$ban_doc = new Document('banned');
if ($user->banned == User::BANNED_BY_USER_ID) {
    $ban = queryGetRow("select u1.ban_date as ban_date, u2.name as banned_by, u1.ban_reason as ban_reason\r\n                        from {$table['user']} u1, {$table['user']} u2\r\n                        where u1.id = ? and u2.id = u1.banned_by", $user->id);
    $ban_doc->set('ban', "User <b>{$user->name}</b> is banned until <b>{$ban['ban_date']}</b> by <b>{$ban['banned_by']}</b>.");
    $ban_doc->set('logout', "<a href='logout.php'><button>Log out</button></a>");
} else {
    $ban = queryGetRow("select t1.ban_date as ban_date, u2.name as banned_by, t1.ban_reason as ban_reason\r\n                        from {$table['ip_data']} t1, {$table['user']} u2\r\n                        where t1.ip = ? and u2.id = t1.banned_by", $user->ip);
    $ban_doc->set('ban', "Your ip address <b>{$user->ip}</b> is banned until <b>{$ban['ban_date']}</b> by <b>{$ban['banned_by']}</b>.");
}
$ban_doc->set('reason', $ban['ban_reason']);
$doc->content = $ban_doc->render();
echo $doc->render();
开发者ID:aaronboo95,项目名称:chiitrans,代码行数:18,代码来源:banned.php

示例9: testStoreNewDocumentThenReplace

 /**
  * Test for correct exception codes if nonexistent objects are tried to be gotten, replaced, updated or removed
  */
 public function testStoreNewDocumentThenReplace()
 {
     //Setup
     $document = new Document();
     $document->set('data', 'this is some test data');
     //Check that the document is new
     $this->assertTrue($document->getIsNew(), 'Document is not marked as new when it is a new document.');
     $documentHandler = $this->documentHandler;
     //Store the document
     $id = $documentHandler->store($document, $this->collection->getId());
     $rev = $document->getRevision();
     $this->assertTrue($id == $document->getId(), 'Returned ID does not match the one in the document');
     $this->assertTrue($document->get('data') == 'this is some test data', 'Data has been modified for some reason.');
     //Check that the document is not new
     $this->assertTrue(!$document->getIsNew(), 'Document is marked as new when it is not.');
     //Update the document and save again
     $document->set('data', 'this is some different data');
     $document->set('favorite_sport', 'hockey');
     $documentHandler->store($document);
     //Check that the id remains the same
     $this->assertTrue($document->getId() == $id, 'ID of updated document does not match the initial ID.');
     //Retrieve a copy of the document from the server
     $document = $documentHandler->get($this->collection->getId(), $id);
     //Assert that it is not new
     $this->assertTrue(!$document->getIsNew(), 'Document is marked as new when it is not.');
     //Assert the id is the same
     $this->assertTrue($document->getId() == $id, 'ID of retrieved document does not match expected ID');
     //Assert new data has been saved
     $this->assertTrue($document->get('favorite_sport') == 'hockey', 'Retrieved data does not match.');
     $this->assertTrue($document->getRevision() != $rev, 'Revision matches when it is not suppose to.');
 }
开发者ID:TomSearch,项目名称:arangodb-php-docs,代码行数:34,代码来源:DocumentExtendedTest.php

示例10: testDocumentLength

 function testDocumentLength()
 {
     $d = new Document(3);
     $d->set(array('pricecode' => 'this should be only t', 'youtube' => 'youtube is required to be 16 chars, max'));
     $d = new Document(3);
     $this->assertEquals('t', $d->pricecode());
     $this->assertEquals(16, strlen($d->youtube()));
 }
开发者ID:songwork,项目名称:songwork,代码行数:8,代码来源:testDocument.php

示例11: Document

     // collection may already exist - ignore this error for now
 }
 // create a new document
 $user = new Document();
 $user->set("name", "John");
 $user->age = 19;
 $id = $handler->save("users", $user);
 // get documents by example
 $cursor = $collectionHandler->byExample("users", array("name" => "John", "age" => 19));
 var_dump($cursor->getAll());
 // get the ids of all documents in the collection
 $result = $handler->getAllIds("users");
 var_dump($result);
 // create another new document
 $user = new Document();
 $user->set("name", "j-lo");
 $user->level = 1;
 $user->vists = array(1, 2, 3);
 $id = $handler->save("users", $user);
 var_dump("CREATED A NEW DOCUMENT WITH ID: ", $id);
 // get this document from the server
 $userFromServer = $handler->getById("users", $id);
 var_dump($userFromServer);
 // update this document
 $userFromServer->nonsense = "hihi";
 unset($userFromServer->name);
 $result = $handler->update($userFromServer);
 var_dump($result);
 // get the updated document back
 $result = $handler->get("users", $id);
 var_dump($result);
开发者ID:vinigomescunha,项目名称:ArangoDB-Ajax-PHP-Example,代码行数:31,代码来源:document.php

示例12: set

 /**
  * Set a graph attribute
  *
  * The key (attribute name) must be a string.
  * This will validate the value of the attribute and might throw an
  * exception if the value is invalid.
  *
  * @throws ClientException
  *
  * @param string $key    - attribute name
  * @param mixed  $value  - value for attribute
  *
  * @return void
  */
 public function set($key, $value)
 {
     if ($key === self::ENTRY_EDGE_DEFINITIONS) {
         if ($this->_doValidate) {
             ValueValidator::validate($value);
         }
         foreach ($value as $ed) {
             $edgeDefinition = new EdgeDefinition();
             foreach ($ed[self::ENTRY_FROM] as $from) {
                 $edgeDefinition->addFromCollection($from);
             }
             foreach ($ed[self::ENTRY_TO] as $to) {
                 $edgeDefinition->addToCollection($to);
             }
             $edgeDefinition->setRelation($ed[self::ENTRY_COLLECTION]);
             $this->addEdgeDefinition($edgeDefinition);
         }
     } else {
         if ($key === self::ENTRY_ORPHAN_COLLECTIONS) {
             if ($this->_doValidate) {
                 ValueValidator::validate($value);
             }
             foreach ($value as $o) {
                 $this->addOrphanCollection($o);
             }
         } else {
             parent::set($key, $value);
         }
     }
 }
开发者ID:vinigomescunha,项目名称:ArangoDB-Ajax-PHP-Example,代码行数:44,代码来源:Graph.php


注:本文中的Document::set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。