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


PHP PropelCollection::contains方法代码示例

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


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

示例1: testAdd

    /**
    * Test that PropelCollection->add() prevents duplicates of objects strictly identical
    *
    */
   public function testAdd()
    {
        Propel::disableInstancePooling();
        $eleve1 = EleveQuery::create()->findOneByLogin('Florence Michu');
        $eleve1->setNom('test_different');
        $eleve_col = new PropelCollection();
        $eleve_col->add($eleve1);
        $eleve1idem = EleveQuery::create()->findOneByLogin('Florence Michu');
        $this->assertFalse($eleve_col->contains($eleve1idem));
        $eleve_col->add($eleve1idem);
        $this->assertEquals(2, count($eleve_col));
        Propel::enableInstancePooling();


        $eleve1 = EleveQuery::create()->findOneByLogin('Florence Michu');
        $eleve_col = new PropelCollection();
        $eleve_col->add($eleve1);
        $eleve_col->add($eleve1);
        $this->assertEquals(1, count($eleve_col));
    }
开发者ID:rhertzog,项目名称:lcs,代码行数:24,代码来源:PropelCollectionTest.php

示例2: contains

 /**
  * {@inheritdoc}
  */
 public function contains($element)
 {
     if ($element instanceof BaseObject) {
         if (null !== ($elt = $this->getIdenticalObject($element))) {
             $element = $elt;
         }
     }
     return parent::contains($element);
 }
开发者ID:szabobeni,项目名称:benstore,代码行数:12,代码来源:PropelObjectCollection.php

示例3: diff

 /**
  * Returns an array of objects present in the collection that
  * are not presents in the given collection.
  *
  * @param PropelCollection $collection	A Propel collection.
  * @return PropelCollection				An array of Propel objects from the collection that are not presents in the given collection.
  */
 public function diff(PropelCollection $collection)
 {
     $diff = clone $this;
     $diff->clear();
     foreach ($this as $object) {
         if (!$collection->contains($object)) {
             $diff[] = $object;
         }
     }
     return $diff;
 }
开发者ID:ketheriel,项目名称:ETVA,代码行数:18,代码来源:PropelCollection.php

示例4: testContains

 public function testContains()
 {
     $col = new PropelCollection();
     $this->assertFalse($col->contains('foo_1'), 'contains() returns false on an empty collection');
     $data = array('bar1', 'bar2', 'bar3');
     $col = new PropelCollection($data);
     $this->assertTrue($col->contains('bar1'), 'contains() returns true when the key exists');
     $this->assertFalse($col->contains('bar4'), 'contains() returns false when the key does not exist');
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:9,代码来源:PropelCollectionTest.php


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