本文整理匯總了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;
}