本文整理汇总了PHP中PropelCollection::getArrayCopy方法的典型用法代码示例。如果您正苦于以下问题:PHP PropelCollection::getArrayCopy方法的具体用法?PHP PropelCollection::getArrayCopy怎么用?PHP PropelCollection::getArrayCopy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropelCollection
的用法示例。
在下文中一共展示了PropelCollection::getArrayCopy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetData
public function testSetData()
{
$col = new PropelCollection();
$col->setData(array());
$this->assertEquals(array(), $col->getArrayCopy(), 'setData() can set data to an empty array');
$data = array('bar1', 'bar2', 'bar3');
$col = new PropelCollection();
$col->setData($data);
$this->assertEquals($data, $col->getArrayCopy(), 'setData() sets the collection data');
}
示例2: getArrayCopy
/**
* Synonym for toArray(), to provide a similar interface to PopelObjectCollection
*
* @param string $keyColumn
* @param boolean $usePrefix
*
* @return array
*/
public function getArrayCopy($keyColumn = null, $usePrefix = false)
{
if (null === $keyColumn && false === $usePrefix) {
return parent::getArrayCopy();
} else {
return $this->toArray($keyColumn, $usePrefix);
}
}
示例3: getArrayCopy
/**
* Get an array representation of the collection
*
* @param string $keyColumn If null, the returned array uses an incremental index.
* Otherwise, the array is indexed using the specified column
* @param boolean $usePrefix If true, the returned array prefixes keys
* with the model class name ('Article_0', 'Article_1', etc).
*
* <code>
* $bookCollection->getArrayCopy();
* array(
* 0 => $book0,
* 1 => $book1,
* )
* $bookCollection->getArrayCopy('Id');
* array(
* 123 => $book0,
* 456 => $book1,
* )
* $bookCollection->getArrayCopy(null, true);
* array(
* 'Book_0' => $book0,
* 'Book_1' => $book1,
* )
* </code>
*
* @return array
*/
public function getArrayCopy($keyColumn = null, $usePrefix = false)
{
if (null === $keyColumn && false === $usePrefix) {
return parent::getArrayCopy();
}
$ret = array();
$keyGetterMethod = 'get' . $keyColumn;
foreach ($this as $key => $obj) {
$key = null === $keyColumn ? $key : $obj->{$keyGetterMethod}();
$key = $usePrefix ? $this->getModel() . '_' . $key : $key;
$ret[$key] = $obj;
}
return $ret;
}