本文整理汇总了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));
}
示例2: contains
/**
* {@inheritdoc}
*/
public function contains($element)
{
if ($element instanceof BaseObject) {
if (null !== ($elt = $this->getIdenticalObject($element))) {
$element = $elt;
}
}
return parent::contains($element);
}
示例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;
}
示例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');
}