當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。