本文整理汇总了PHP中Address::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Address::load方法的具体用法?PHP Address::load怎么用?PHP Address::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Address
的用法示例。
在下文中一共展示了Address::load方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: AddressBusiness
$addressBusiness = new AddressBusiness(array('countryName' => 'Uganda', 'subdivision' => 'Region', 'cityName' => 'Villageland', 'streetAddress1' => '1251', 'streetAddress2' => '265'));
echo $addressBusiness->display();
echo '<h2>Debugging AddressBusiness</h2>';
echo '<tt><pre>' . var_export($addressBusiness, true) . '</pre></tt>';
echo '<h2>Address2 __toString</h2>';
echo $addressBusiness;
echo '<h2>Displaying address types</h2>';
echo '<pre>' . var_export(Address::$validAddressTypes, true) . '</pre>';
echo '<h2>Testing validation of the address id</h2>';
for ($id = 0; $id <= 4; $id++) {
echo '<div> ' . $id . ':';
echo Address::isValidAddressTypeId($id) ? 'Valid' : 'Invalid';
echo '</div>';
}
echo '<h2>Address Park</h2>';
$addressPark = new AddressPark(array('cityName' => 'Hamlet', 'subdivision' => 'Territory'));
echo $addressPark->display();
echo '<pre>' . var_export($addressPark, true) . '</pre>';
echo '<h2>Testing type casting to an object</h2>';
$test_object_cast = (object) array('john' => 'kagga', 'other' => array('key' => 'value'));
echo '<pre>' . var_export($test_object_cast, true) . '</pre>';
echo '<h2>Testing type casting to an object using numbers</h2>';
$test_object_cast_numbers = (object) 12354;
echo '<pre>' . var_export($test_object_cast_numbers, true) . '</pre>';
echo '<h2>Loading object from database</h2>';
try {
$db_object = Address::load(0);
echo '<pre>' . var_export($db_object, true) . '</pre>';
} catch (ExceptionAddress $e) {
echo $e;
}
示例2: AddressBusiness
$address_business = new AddressBusiness(array('street_address_1' => '123 phony Ave.', 'city_name' => 'Villageland', 'subdivision_name' => 'Region', 'country_name' => 'Canada'));
echo $address_business;
echo '<tt><pre>' . var_export($address_business, TRUE) . '</pre></tt>';
echo '<h2>Instantiating AddressPark</h2>';
$address_park = new AddressPark(array('street_address_1' => '789 Missing Circle', 'street_address_2' => 'Suite 0', 'city_name' => 'Hamlet', 'subdivision_name' => 'Territory', 'country_name' => 'Australia'));
echo $address_park;
echo '<tt><pre>' . var_export($address_park, TRUE) . '</pre></tt>';
echo '<h2>Cloning AddressPark</h2>';
$address_park_clone = clone $address_park;
echo '<tt><pre>' . var_export($address_park_clone, TRUE) . '</pre></tt>';
echo '$address_park_clone is ' . ($address_park == $address_park_clone ? '' : 'not ') . ' a copy of $address_park.';
echo '<h2>Copying AddressBusiness reference</h2>';
$address_business_copy = $address_business;
echo '$address_business_copy is ' . ($address_business == $address_business_copy ? '' : 'not ') . ' a copy of $address_business.';
echo '<h2>Setting address_business as a new AddressPark</h2>';
$address_business = new AddressPark();
echo '$address_business_copy is ' . ($address_business == $address_business_copy ? '' : 'not ') . ' a copy of $address_business.';
echo '<br />$address_business is class ' . get_class($address_business) . '.';
echo '<br />$address_business_copy is ' . ($address_business_copy instanceof AddressBusiness ? '' : 'not ') . ' an AddressBusiness.';
echo '<h2>Testing typecasting to an object</h2>';
$test_object = (object) array('hello' => 'world', 'nested' => array('key' => 'value'));
echo '<tt><pre>' . var_export($test_object, TRUE) . '</pre></tt>';
$test_object_string = (object) 12345;
echo '<tt><pre>' . var_export($test_object_string, TRUE) . '</pre></tt>';
echo '<h2>Loading from the Dataabase</h2>';
try {
$address_db = Address::load(0);
echo '<tt><pre>' . var_export($address_db, TRUE) . '</pre></tt>';
} catch (ExceptionAddress $e) {
echo $e;
}
示例3: __autoload
<?php
/**
* Define autoloader.
* @param string $class_name
*/
function __autoload($class_name)
{
include 'class.' . $class_name . '.inc';
}
echo '<h2>Instantiating AddressResidence</h2>';
$address_residence = new AddressResidence();
echo '<h2>Setting properties...</h2>';
$address_residence->street_address_1 = '555 Fake Street';
$address_residence->city_name = 'Townsville';
$address_residence->subdivision_name = 'State';
$address_residence->country_name = 'United States of America';
echo $address_residence;
echo '<tt><pre>' . var_export($address_residence, TRUE) . '</pre></tt>';
echo '<h2>Testing Address __construct with an array</h2>';
$address_business = new AddressBusiness(array('street_address_1' => '123 Phony Ave', 'city_name' => 'Villageland', 'subdivision_name' => 'Region', 'country_name' => 'Canada'));
echo $address_business;
echo '<tt><pre>' . var_export($address_business, TRUE) . '</pre></tt>';
echo '<h2>Instantiating AddressPark</h2>';
$address_park = new AddressPark(array('street_address_1' => '789 Missing Circle', 'street_address_2' => 'Suite 0', 'city_name' => 'Hamlet', 'subdivision_name' => 'Territory', 'country_name' => 'Australia'));
echo $address_park;
echo '<tt><pre>' . var_export($address_park, TRUE) . '</pre></tt>';
echo '<h2>Loading from database</h2>';
$address_db = Address::load(1);
echo '<tt><pre>' . var_export($address_db, TRUE) . '</pre></tt>';
示例4: var_export
echo '<code><pre>' . var_export($addr1, true) . '</pre></code>';
echo $addr1;
echo '<h3>Setting AddressBusiness properties</h3>';
// postal_code is read from database
$addr2 = new AddressBusiness(array('street_address_1' => '400 Walt Disney Way', 'city_name' => 'Hawthorne', 'subdivision_name' => 'California'));
echo '<h3>Displaying AddressBusiness</h3>';
echo '<code><pre>' . var_export($addr2, true) . '</pre></code>';
echo $addr2;
echo '<h3>Instantiating AddressPark</h3>';
$addr3 = new AddressPark(array('street_address_1' => '789 Missing Circle', 'street_address_2' => 'Suite 0', 'city_name' => 'Hamlet', 'subdivision_name' => 'Territory'));
echo '<code><pre>' . var_export($addr3, TRUE) . '</pre></code>';
echo $addr3;
/*
echo '<h3>Cloning AddressPark</h3>';
$addr4 = clone $addr3;
echo '<code><pre>' . var_export($addr4, TRUE) . '</pre></code>';
echo 'address park clone is ' . ($addr3 == $addr4 ?
'' : 'not ') . ' a copy of address park.';
*/
echo '<h3>Testing typecasting to an object</h3>';
$test_object = (object) 12345;
echo '<tt><pre>' . var_export($test_object, TRUE) . '</pre></tt>';
echo '<h3>Saving AddressResidence</h3>';
// $addr1->save();
echo '<h3>Load AddressResidence</h3>';
$addr4 = Address::load(2);
echo '<h3>Displaying AddressResidence</h3>';
echo '<code><pre>' . var_export($addr4, true) . '</pre></code>';
echo $addr4;
示例5: Address
include 'class.' . $class_name . '.inc';
}
echo '<h2>Instantiating a residence address</h2>';
$add = new Address();
$add->street_address_1 = '3098, du Finistere';
$add->city_name = 'Ste-Foy';
$add->subdivision_name = 'Quebec';
$add->country_name = 'Canada';
$add->address_type_id = '1';
echo $add;
echo '<h2>Testing address __contsruct function</h2>';
$add2 = new Address(array('street_address_1' => '3098, Finest', 'street_address_2' => 'app.#3', 'city_name' => 'Rockwood City', 'subdivision_name' => 'California', 'country_name' => 'USA'));
echo $add2;
echo '<h2>Creating an AddressBusiness instance</h2>';
$address_bus_data = array('address_type_id' => 2, 'street_address_1' => '18 Bay Street', 'city_name' => 'Toronto', 'country_name' => 'Canada');
$address_bus = new AddressBusiness($address_bus_data);
echo '<tt><pre>' . var_export($address_bus, TRUE) . '</pre></tt>';
echo '<h2>Loading from database and creating an instance of an Address subclass';
echo ' based on the value of the _address_type_id</h2>';
$address_sub = Address::load(2);
echo '<tt><pre>' . var_export($address_sub, TRUE) . '</pre></tt>';
echo '<h2>Now adding address_bus in database passing data array</h2>';
Address::populateDatabase($address_bus_data);
echo '<h2>Now adding another address in database by calling the Address constructor</h2>';
$addnew = new Address();
$addnew->street_address_1 = '337 Ernie Els';
$addnew->city_name = 'Jackman';
$addnew->subdivision_name = 'Maine';
$addnew->country_name = 'USA';
$addnew->address_type_id = '3';
$addnew->populateDBFromAddress();
示例6: testHasOne
/**
* Has one
*/
public function testHasOne()
{
ORM::init('mysql:host=localhost;dbname=rocket_orm', 'orm_username', 'orm_password');
$user = Address::load(1)->user();
$this->assertEquals(get_class($user), 'User');
$this->assertEquals($user->get('user_id'), '1');
}
示例7: get_from_id
public static function get_from_id($id)
{
$address = new Address();
$address->load($id);
return $address;
}