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


PHP DataMapper::load方法代码示例

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


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

示例1: testShouldRemoveParents

 function testShouldRemoveParents()
 {
     $mapper = new DataMapper($this->db);
     $truck_id = $mapper->save(array('name' => 'truck'));
     $wheel_id = $mapper->save(array('name' => 'wheel', 'paths' => array($truck_id)));
     $mapper->save(array('id' => $wheel_id, 'name' => 'wheel', 'paths' => array()));
     $category = $mapper->load($wheel_id);
     $this->assertEquals(array(), $category['paths'], 'should remove paths');
 }
开发者ID:metator,项目名称:application,代码行数:9,代码来源:DataMapperTest.php

示例2: testShouldUpdateAddress

 function testShouldUpdateAddress()
 {
     $address = array('first_name' => 'Joshua', 'last_name' => 'Ribakoff', 'email' => 'josh.ribakoff@gmail.com', 'address' => '123 Test St', 'address2' => 'Suite 5', 'city' => 'Port St Lucie', 'state' => 'FL', 'postal' => '00123', 'country' => 'USA', 'phone' => '0101010101', 'fax' => '0202020202');
     $addressMapper = new DataMapper($this->db);
     $id = $addressMapper->save($address);
     $updatedAddress = array('id' => $id, 'first_name' => 'Joshua-updated', 'last_name' => 'Ribakoff-updated', 'email' => 'josh.ribakoff-updated@gmail.com', 'address' => '123 Test St-updated', 'address2' => 'Suite 5-updated', 'city' => 'Port St Lucie-updated', 'state' => 'FL-updated', 'postal' => '12345', 'country' => 'USA-updated', 'phone' => '111111111', 'fax' => '2222222222');
     $addressMapper = new DataMapper($this->db);
     $id = $addressMapper->save($updatedAddress);
     $loadedAddress = $addressMapper->load($id);
     $this->assertSame($updatedAddress, $loadedAddress, 'should save new address');
 }
开发者ID:metator,项目名称:application,代码行数:11,代码来源:DataMapperTest.php

示例3: testShouldSaveCartAndItems

 function testShouldSaveCartAndItems()
 {
     $cart = new \Metator\Cart\Cart();
     $cart->add(1, 9.99);
     $cart->add(2, 4.99);
     $cart->setQuantity(2, 2);
     $order = array('items' => $cart, 'created' => '0000-00-00 00:00:00');
     $orderMapper = new DataMapper($this->db);
     $id = $orderMapper->save($order, null);
     $reloaded_order = $orderMapper->load($id);
     $this->assertEquals(array(1, 2), $reloaded_order['items']->items(), 'should save items');
 }
开发者ID:metator,项目名称:application,代码行数:12,代码来源:DataMapperTest.php

示例4: testShouldConvertNullToEmptyCategories

 function testShouldConvertNullToEmptyCategories()
 {
     $product_mapper = new DataMapper($this->db);
     $product = new Product(array('sku' => 'foo2'));
     $product->setCategories(null);
     $product_mapper->save($product);
     $product = $product_mapper->load($product->id());
     $this->assertEquals(array(), $product->getCategories(), 'should convert NULL to empty categories');
 }
开发者ID:metator,项目名称:application,代码行数:9,代码来源:DataMapperTest.php


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