本文整理汇总了PHP中Property::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Property::set方法的具体用法?PHP Property::set怎么用?PHP Property::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Property
的用法示例。
在下文中一共展示了Property::set方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: factoryMethod
protected function factoryMethod()
{
$product = new Postac2();
$property = new Property();
$property->set('actionpkt', 0);
$property->set('imie', 'Piotr');
$property->set('sila', 10);
$property->set('zycie', 20);
$property->set('speed', 15);
$product->setProperties($property);
return $product;
}
示例2: set
public function set($val)
{
parent::set($val);
if ($val instanceof IFileUpload)
{
$this->_value->setStoreManager(CoOrg::getDataManager($this->_dataPath));
}
}
示例3: test_for_has_and_belongs_to_many
public function test_for_has_and_belongs_to_many()
{
$Property = new Property(array('description' => 'Gandia Palace'));
$this->assertEqual($Property->property_type->getType(), 'hasAndBelongsToMany');
$this->assertTrue(is_array($Property->property_types) && count($Property->property_types) === 0);
$Property->property_type->load();
$this->assertEqual($Property->property_type->count(), 0);
$Chalet = new PropertyType(array('description' => 'Chalet'));
$Property->property_type->add($Chalet);
$this->assertEqual($Property->property_type->count(), 1);
$this->assertReference($Property->property_types[0], $Chalet);
$Property->property_type->add($Chalet);
$this->assertEqual($Property->property_type->count(), 1);
$Condo = new PropertyType(array('description' => 'Condominium'));
$Property->property_type->add($Condo);
$this->assertEqual($Property->property_type->count(), 2);
$this->assertTrue($Property->save());
$this->assertFalse($Chalet->isNewRecord());
$this->assertFalse($Condo->isNewRecord());
$this->assertTrue($Chalet = $Chalet->findFirstBy('description', 'Chalet', array('include' => 'properties')));
$this->assertEqual($Chalet->properties[0]->getId(), $Property->getId());
$this->assertTrue($Condo = $Condo->findFirstBy('description', 'Condominium', array('include' => 'properties')));
$this->assertEqual($Condo->properties[0]->getId(), $Property->getId());
$this->assertReference($Chalet, $Property->property_types[0]);
$this->assertReference($Condo, $Property->property_types[1]);
$Property = new Property($Property->getId());
$Property->property_type->load();
$this->assertEqual($Property->property_type->association_id, 'property_types');
$this->assertEqual($Property->property_type->count(), 2);
$Property->property_types = array();
$this->assertEqual($Property->property_type->count(), 0);
$Property->property_type->load();
$this->assertEqual($Property->property_type->count(), 0);
$Property->property_type->load(true);
$this->assertEqual($Property->property_type->count(), 2);
$this->assertEqual($Property->property_types[1]->getType(), 'PropertyType');
$Property->property_type->delete($Property->property_types[1]);
$this->assertEqual($Property->property_type->count(), 1);
$Property->property_type->load(true);
$this->assertEqual($Property->property_type->count(), 1);
$Property =& $Property->findFirstBy('description', 'Gandia Palace');
$PropertyType = new PropertyType();
$PropertyTypes =& $PropertyType->find();
$Property->property_type->set($PropertyTypes);
$this->assertEqual($Property->property_type->count(), count($PropertyTypes));
$Property =& $Property->findFirstBy('description', 'Gandia Palace');
$Property->property_type->load();
$this->assertEqual($Property->property_type->count(), count($PropertyTypes));
$Property =& $Property->findFirstBy('description', 'Gandia Palace');
$PropertyType->set('description', 'Palace');
$Property->property_type->set($PropertyType);
$this->assertEqual($Property->property_type->count(), 1);
$this->assertTrue(in_array('property_types', $Property->getAssociatedIds()));
$Property = $Property->findFirstBy('description', 'Gandia Palace', array('include' => 'property_types'));
$this->assertIdentical($Property->property_type->count(), 1);
$this->assertTrue($Property->property_type->delete($Property->property_types[0]));
$this->assertIdentical($Property->property_type->count(), 0);
$Property = $Property->findFirstBy('description', 'Gandia Palace');
$this->assertIdentical($Property->property_type->count(), 0);
// It should return existing Property even if it doesnt have property_types
$this->assertTrue($Property->findFirstBy('description', 'Gandia Palace', array('include' => 'property_types')));
$Property = new Property(array('description' => 'Luxury Downtown House'));
$Apartment =& $PropertyType->create(array('description' => 'Apartment'));
$Loft =& $PropertyType->create(array('description' => 'Loft'));
$Penthouse =& $PropertyType->create(array('description' => 'Penthouse'));
$Property->property_type->setByIds(array($Apartment->getId(), $Loft->getId(), $Penthouse->getId()));
$this->assertEqual($Property->property_type->count(), 3);
$this->assertTrue($Property->save());
$this->assertTrue($Property->save());
$this->assertTrue($Property =& $Property->findFirstBy('description', 'Luxury Downtown House'));
$Property->property_type->load();
$this->assertEqual($Property->property_type->count(), 3);
$FoundApartment = $Property->property_type->find('first', array('description' => 'Apartment'));
$this->assertEqual($Apartment->get('description') . $Apartment->getId(), $FoundApartment->get('description') . $FoundApartment->getId());
$FoundTypes = $Property->property_type->find();
$this->assertEqual(count($FoundTypes), $Property->property_type->count());
$descriptions = array();
foreach ($FoundTypes as $FoundType) {
$descriptions[] = $FoundType->get('description');
}
sort($descriptions);
$this->assertEqual($descriptions, array('Apartment', 'Loft', 'Penthouse'));
$this->assertFalse($Property->property_type->isEmpty());
$this->assertEqual($Property->property_type->getSize(), 3);
$this->assertTrue($Property->property_type->clear());
$this->assertTrue($Property->property_type->isEmpty());
$this->assertEqual($Property->property_type->getSize(), 0);
$Property = new Property();
$LandProperty =& $Property->property_type->build(array('description' => 'Land'));
$this->assertReference($LandProperty, $Property->property_types[0]);
$this->assertTrue($Property->property_types[0]->isNewRecord());
$this->assertEqual($LandProperty->getType(), 'PropertyType');
$Property->set('description', 'Plot of Land in Spain');
$this->assertTrue($Property->save());
$this->assertTrue($LandProperty = $Property->findFirstBy('description', 'Plot of Land in Spain', array('include' => 'property_types')));
$this->assertEqual($LandProperty->property_types[0]->get('description'), 'Land');
$Property = new Property(array('description' => 'Seaside house in Altea'));
$SeasidePropertyType =& $Property->property_type->create(array('description' => 'Seaside property'));
$this->assertReference($SeasidePropertyType, $Property->property_types[0]);
$this->assertTrue($SeasidePropertyType->isNewRecord());
//.........这里部分代码省略.........
示例4: set
public function set($v)
{
parent::set(trim($v));
}
示例5: test_for_has_many
public function test_for_has_many()
{
$Property = new Property();
$this->assertEqual($Property->picture->getType(), 'hasMany');
$this->assertTrue(is_array($Property->pictures) && count($Property->pictures) === 0);
$Property->picture->load();
$this->assertEqual($Property->picture->count(), 0);
$SeaViews = new Picture(array('title' => 'Sea views'));
$Property->picture->add($SeaViews);
$this->assertEqual($Property->picture->count(), 1);
$this->assertReference($Property->pictures[0], $SeaViews);
$Property->picture->add($SeaViews);
$this->assertEqual($Property->picture->count(), 1);
$this->assertNull($Property->pictures[0]->get('property_id'));
$MountainViews = new Picture(array('title' => 'Mountain views'));
$this->assertTrue($MountainViews->isNewRecord());
$Property->picture->add($MountainViews);
$this->assertEqual($Property->picture->count(), 2);
$this->assertTrue($Property->save());
$this->assertFalse($SeaViews->isNewRecord());
$this->assertFalse($MountainViews->isNewRecord());
$this->assertEqual($SeaViews->get('property_id'), $Property->getId());
$this->assertEqual($MountainViews->get('property_id'), $Property->getId());
$this->assertReference($SeaViews, $Property->pictures[0]);
$this->assertReference($MountainViews, $Property->pictures[1]);
$Property = new Property($Property->getId());
$Property->picture->load();
$this->assertEqual($Property->picture->association_id, 'pictures');
$this->assertEqual($Property->picture->count(), 2);
$Property->pictures = array();
$this->assertEqual($Property->picture->count(), 0);
$Property->picture->load();
$this->assertEqual($Property->picture->count(), 0);
$Property->picture->load(true);
$this->assertEqual($Property->picture->count(), 2);
$this->assertEqual($Property->pictures[1]->getType(), 'Picture');
$Property->picture->delete($Property->pictures[1]);
$this->assertEqual($Property->picture->count(), 1);
$Property->picture->load(true);
$this->assertEqual($Property->picture->count(), 1);
$Property = $Property->find('first');
$Picture = new Picture();
$Pictures = $Picture->find();
$Property->picture->set($Pictures);
$this->assertEqual($Property->picture->count(), count($Pictures));
$Property = $Property->find('first');
$Property->picture->load();
$this->assertEqual($Property->picture->count(), count($Pictures));
$Picture = $Picture->find('first');
$Property->picture->set($Picture);
$this->assertEqual($Property->picture->count(), 1);
$this->assertTrue(in_array('pictures', $Property->getAssociatedIds()));
$Property = $Property->find('first', array('include' => 'pictures'));
$this->assertIdentical($Property->picture->count(), 1);
$this->assertEqual($Property->pictures[0]->getId(), $Picture->getId());
$this->assertTrue($Property->picture->delete($Property->pictures[0]));
$this->assertIdentical($Property->picture->count(), 0);
$Property =& $Property->find('first');
$this->assertIdentical($Property->picture->count(), 0);
//$this->assertTrue($Property =& $Property->find('first', array('include'=>'pictures')));
//$this->assertIdentical($Property->picture->count(), 0);
$Picture = new Picture();
$Alicia =& $Picture->create(array('title' => 'Alicia'));
$Bermi =& $Picture->create(array('title' => 'Bermi'));
$Hilario =& $Picture->create(array('title' => 'Hilario'));
$Property->picture->setByIds(array($Alicia->getId(), $Bermi->getId(), $Hilario->getId()));
$Property->set('description', 'Cool house');
$this->assertTrue($Property->save());
$this->assertTrue($Property =& $Property->findFirstBy('description', 'Cool house'));
$Property->picture->load();
$this->assertEqual($Property->picture->count(), 3);
$FoundAlicia = $Property->picture->find('first', array('conditions' => array('title = ?', "Alicia")));
$this->assertEqual($Alicia->get('title') . $Alicia->getId(), $FoundAlicia->get('title') . $FoundAlicia->getId());
$FoundPals = $Property->picture->find();
$this->assertEqual(count($FoundPals), $Property->picture->count());
$titles = array();
foreach ($FoundPals as $FoundPal) {
$titles[] = $FoundPal->get('title');
}
sort($titles);
$this->assertEqual($titles, array('Alicia', 'Bermi', 'Hilario'));
$this->assertFalse($Property->picture->isEmpty());
$this->assertEqual($Property->picture->getSize(), 3);
$this->assertTrue($Property->picture->clear());
$this->assertTrue($Property->picture->isEmpty());
$this->assertEqual($Property->picture->getSize(), 0);
$Property = new Property();
$PoolPicture =& $Property->picture->build(array('title' => 'Pool'));
$this->assertReference($PoolPicture, $Property->pictures[0]);
$this->assertTrue($Property->pictures[0]->isNewRecord());
$this->assertEqual($PoolPicture->getType(), 'Picture');
$Property->set('description', 'Maui Estate');
$this->assertTrue($Property->save());
$this->assertTrue($MauiEstate = $Property->findFirstBy('description', 'Maui Estate', array('include' => 'pictures')));
$this->assertEqual($MauiEstate->pictures[0]->get('title'), 'Pool');
$Property = new Property(array('description' => 'Villa Altea'));
$GardenPicture =& $Property->picture->create(array('title' => 'Garden'));
$this->assertReference($GardenPicture, $Property->pictures[0]);
$this->assertTrue($GardenPicture->isNewRecord());
$Property = new Property(array('description' => 'Villa Altea'));
//.........这里部分代码省略.........