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


PHP Property::findFirstBy方法代码示例

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


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

示例1: test_associated_uniqueness

 public function test_associated_uniqueness()
 {
     $Property = new Property();
     $PropertyType = new PropertyType();
     $this->assertTrue($RanchoMaria =& $Property->create(array('description' => 'Rancho Maria')));
     $this->assertTrue($Rancho =& $PropertyType->create(array('description' => 'Rancho')));
     $Rancho->property->load();
     $this->assertEqual($Rancho->property->count(), 0);
     $Rancho->property->add($RanchoMaria);
     $this->assertEqual($Rancho->property->count(), 1);
     $this->assertTrue($RanchoMaria =& $Property->findFirstBy('description', 'Rancho Maria'));
     $this->assertTrue($Rancho =& $PropertyType->findFirstBy('description', 'Rancho', array('include' => 'properties')));
     $Rancho->property->add($RanchoMaria);
     $this->assertEqual($Rancho->property->count(), 1);
     $Rancho->set('description', 'Rancho Type');
     $this->assertTrue($Rancho->save());
     $this->assertTrue($Rancho =& $PropertyType->findFirstBy('description', 'Rancho Type', array('include' => 'properties')));
     $this->assertEqual($Rancho->property->count(), 1);
 }
开发者ID:joeymetal,项目名称:v1,代码行数:19,代码来源:AkHasAndBelongsToMany.php

示例2: 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'));
//.........这里部分代码省略.........
开发者ID:joeymetal,项目名称:v1,代码行数:101,代码来源:AkHasMany.php


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