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


PHP RedBean_OODBBean::import方法代码示例

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


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

示例1: testImportFromAndTainted

 /**
  * Test import from and tainted.
  * 
  * @return void
  */
 public function testImportFromAndTainted()
 {
     testpack('Test importFrom() and Tainted');
     $bean = R::dispense('bean');
     R::store($bean);
     $bean->name = 'abc';
     asrt($bean->getMeta('tainted'), TRUE);
     R::store($bean);
     asrt($bean->getMeta('tainted'), FALSE);
     $copy = R::dispense('bean');
     R::store($copy);
     $copy = R::load('bean', $copy->id);
     asrt($copy->getMeta('tainted'), FALSE);
     $copy->import(array('name' => 'xyz'));
     asrt($copy->getMeta('tainted'), TRUE);
     $copy->setMeta('tainted', FALSE);
     asrt($copy->getMeta('tainted'), FALSE);
     $copy->importFrom($bean);
     asrt($copy->getMeta('tainted'), TRUE);
     testpack('Test basic import() feature.');
     $bean = new RedBean_OODBBean();
     $bean->import(array("a" => 1, "b" => 2));
     asrt($bean->a, 1);
     asrt($bean->b, 2);
     $bean->import(array("a" => 3, "b" => 4), "a,b");
     asrt($bean->a, 3);
     asrt($bean->b, 4);
     $bean->import(array("a" => 5, "b" => 6), " a , b ");
     asrt($bean->a, 5);
     asrt($bean->b, 6);
     $bean->import(array("a" => 1, "b" => 2));
     testpack('Test inject() feature.');
     $coffee = R::dispense('coffee');
     $coffee->id = 2;
     $coffee->liquid = 'black';
     $cup = R::dispense('cup');
     $cup->color = 'green';
     // Pour coffee in cup
     $cup->inject($coffee);
     // Do we still have our own property?
     asrt($cup->color, 'green');
     // Did we pour the liquid in the cup?
     asrt($cup->liquid, 'black');
     // Id should not be transferred
     asrt($cup->id, 0);
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:51,代码来源:Import.php

示例2: put

 /**
  * Handles a REST PUT request.
  * Updates the bean described in the payload array in the database.
  * Returns an array formatted according to RedBeanPHP REST BeanCan
  * formatting specifications.
  *
  * Format of the payload array:
  *
  * array(
  *        'bean' => array( property => value pairs )
  * )
  *
  * @return array
  */
 private function put()
 {
     if (!isset($this->payload['bean'])) {
         return $this->resp(NULL, self::C_HTTP_BAD_REQUEST, 'Missing parameter \'bean\'.');
     }
     if (!is_array($this->payload['bean'])) {
         return $this->resp(NULL, self::C_HTTP_BAD_REQUEST, 'Parameter \'bean\' must be object/array.');
     }
     foreach ($this->payload['bean'] as $key => $value) {
         if (!is_string($key) || !is_string($value)) {
             return $this->resp(NULL, self::C_HTTP_BAD_REQUEST, 'Object "bean" invalid.');
         }
     }
     $this->bean->import($this->payload['bean']);
     $this->oodb->store($this->bean);
     $this->bean = $this->oodb->load($this->bean->getMeta('type'), $this->bean->id);
     return $this->resp($this->bean->export());
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:32,代码来源:BeanCanResty.php

示例3:

asrt($bean->getMeta("nonexistant,nested", "abc"), "abc");
$bean->setMeta("test.two", "second");
asrt($bean->getMeta("test.two"), "second");
$bean->setMeta("another.little.property", "yes");
asrt($bean->getMeta("another.little.property"), "yes");
asrt($bean->getMeta("test.two"), "second");
testpack("UNIT TEST RedBean OODBBean: copyMeta");
$bean = new RedBean_OODBBean();
$bean->setMeta("meta.meta", "123");
$bean2 = new RedBean_OODBBean();
asrt($bean2->getMeta("meta.meta"), NULL);
$bean2->copyMetaFrom($bean);
asrt($bean2->getMeta("meta.meta"), "123");
testpack("UNIT TEST RedBean OODBBean: import");
$bean = new RedBean_OODBBean();
$bean->import(array("a" => 1, "b" => 2));
asrt($bean->a, 1);
asrt($bean->b, 2);
testpack("UNIT TEST RedBean OODBBean: export");
$bean->setMeta("justametaproperty", "hellothere");
$arr = $bean->export();
asrt(is_array($arr), true);
asrt(isset($arr["a"]), true);
asrt(isset($arr["b"]), true);
asrt($arr["a"], 1);
asrt($arr["b"], 2);
asrt(isset($arr["__info"]), false);
$arr = $bean->export(true);
asrt(isset($arr["__info"]), true);
asrt($arr["a"], 1);
asrt($arr["b"], 2);
开发者ID:blocka,项目名称:redbean,代码行数:31,代码来源:test.php

示例4:

asrt($bean->getMeta("nonexistant,nested", "abc"), "abc");
$bean->setMeta("test.two", "second");
asrt($bean->getMeta("test.two"), "second");
$bean->setMeta("another.little.property", "yes");
asrt($bean->getMeta("another.little.property"), "yes");
asrt($bean->getMeta("test.two"), "second");
testpack("UNIT TEST RedBean OODBBean: copyMeta");
$bean = new RedBean_OODBBean();
$bean->setMeta("meta.meta", "123");
$bean2 = new RedBean_OODBBean();
asrt($bean2->getMeta("meta.meta"), NULL);
$bean2->copyMetaFrom($bean);
asrt($bean2->getMeta("meta.meta"), "123");
testpack("UNIT TEST RedBean OODBBean: import");
$bean = new RedBean_OODBBean();
$bean->import(array("a" => 1, "b" => 2));
asrt($bean->a, 1);
asrt($bean->b, 2);
$bean->import(array("a" => 3, "b" => 4), "a,b");
asrt($bean->a, 3);
asrt($bean->b, 4);
$bean->import(array("a" => 5, "b" => 6), " a , b ");
asrt($bean->a, 5);
asrt($bean->b, 6);
$bean->import(array("a" => 1, "b" => 2));
testpack("UNIT TEST RedBean OODBBean: export");
$bean->setMeta("justametaproperty", "hellothere");
$arr = $bean->export();
asrt(is_array($arr), true);
asrt(isset($arr["a"]), true);
asrt(isset($arr["b"]), true);
开发者ID:ryjkov,项目名称:redbean,代码行数:31,代码来源:test.php

示例5: testExportAll

 /**
  * ExportAll.
  * 
  * @return void
  */
 public function testExportAll()
 {
     testpack('Test exportAll');
     $redbean = R::$redbean;
     $bean = new RedBean_OODBBean();
     $bean->import(array("a" => 1, "b" => 2));
     $bean->setMeta("justametaproperty", "hellothere");
     $arr = $bean->export();
     asrt(is_array($arr), TRUE);
     asrt(isset($arr["a"]), TRUE);
     asrt(isset($arr["b"]), TRUE);
     asrt($arr["a"], 1);
     asrt($arr["b"], 2);
     asrt(isset($arr["__info"]), FALSE);
     $arr = $bean->export(TRUE);
     asrt(isset($arr["__info"]), TRUE);
     asrt($arr["a"], 1);
     asrt($arr["b"], 2);
     $exportBean = $redbean->dispense("abean");
     $exportBean->setMeta("metaitem.bla", 1);
     $exportedBean = $exportBean->export(TRUE);
     asrt($exportedBean["__info"]["metaitem.bla"], 1);
     asrt($exportedBean["__info"]["type"], "abean");
     // Can we determine whether a bean is empty?
     testpack('test $bean->isEmpty() function');
     $bean = R::dispense('bean');
     asrt($bean->isEmpty(), TRUE);
     asrt(count($bean) > 0, TRUE);
     $bean->property = 1;
     asrt($bean->isEmpty(), FALSE);
     asrt(count($bean) > 0, TRUE);
     $bean->property = 0;
     asrt($bean->isEmpty(), TRUE);
     asrt(count($bean) > 0, TRUE);
     $bean->property = FALSE;
     asrt($bean->isEmpty(), TRUE);
     asrt(count($bean) > 0, TRUE);
     $bean->property = NULL;
     asrt($bean->isEmpty(), TRUE);
     asrt(count($bean) > 0, TRUE);
     unset($bean->property);
     asrt($bean->isEmpty(), TRUE);
     asrt(count($bean) > 0, TRUE);
     // Export bug I found
     $object = R::graph(json_decode('{"type":"bandmember","name":"Duke","ownInstrument":[{"type":"instrument","name":"Piano"}]}', TRUE));
     $a = R::exportAll($object);
     pass();
     asrt(isset($a[0]), TRUE);
     asrt((int) $a[0]['id'], 0);
     asrt($a[0]['name'], 'Duke');
     asrt($a[0]['ownInstrument'][0]['name'], 'Piano');
     R::nuke();
     $v = R::dispense('village');
     $b = R::dispense('building');
     $v->name = 'a';
     $b->name = 'b';
     $v->ownBuilding[] = $b;
     $id = R::store($v);
     $a = R::exportAll($v);
     asrt($a[0]['name'], 'a');
     asrt($a[0]['ownBuilding'][0]['name'], 'b');
     $v = R::load('village', $id);
     $b2 = R::dispense('building');
     $b2->name = 'c';
     $v->ownBuilding[] = $b2;
     $a = R::exportAll($v);
     asrt($a[0]['name'], 'a');
     asrt($a[0]['ownBuilding'][0]['name'], 'b');
     asrt(count($a[0]['ownBuilding']), 2);
     list($r1, $r2) = R::dispense('army', 2);
     $r1->name = '1';
     $r2->name = '2';
     $v->sharedArmy[] = $r2;
     $a = R::exportAll($v);
     asrt(count($a[0]['sharedArmy']), 1);
     R::store($v);
     $v = R::load('village', $id);
     $a = R::exportAll($v);
     asrt(count($a[0]['sharedArmy']), 1);
     asrt($a[0]['name'], 'a');
     asrt($a[0]['ownBuilding'][0]['name'], 'b');
     asrt(count($a[0]['ownBuilding']), 2);
     $v->sharedArmy[] = $r1;
     $a = R::exportAll($v);
     asrt(count($a[0]['sharedArmy']), 2);
     $v = R::load('village', $id);
     $a = R::exportAll($v);
     asrt(count($a[0]['sharedArmy']), 1);
     $v->sharedArmy[] = $r1;
     R::store($v);
     $v = R::load('village', $id);
     $a = R::exportAll($v);
     asrt(count($a[0]['sharedArmy']), 2);
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:99,代码来源:Export.php


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