本文整理匯總了PHP中Cake\ORM\Query::toArray方法的典型用法代碼示例。如果您正苦於以下問題:PHP Query::toArray方法的具體用法?PHP Query::toArray怎麽用?PHP Query::toArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Cake\ORM\Query
的用法示例。
在下文中一共展示了Query::toArray方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testQueryWithStackedFormatters
/**
* Test fetching results from a qurey with a two custom formatters
*
* @return void
*/
public function testQueryWithStackedFormatters()
{
$table = TableRegistry::get('authors');
$query = new Query($this->connection, $table);
$query->select()->formatResults(function ($results) {
$this->assertInstanceOf('Cake\\ORM\\ResultSet', $results);
return $results->indexBy('id');
});
$query->formatResults(function ($results) {
return $results->extract('name');
});
$expected = [1 => 'mariano', 2 => 'nate', 3 => 'larry', 4 => 'garrett'];
$this->assertEquals($expected, $query->toArray());
}
示例2: _getAllowedCacheKey
/**
* Get allowed cache key.
*
* @param Query $actions
* @param Aro $aro
* @return string
*/
protected function _getAllowedCacheKey(Query $actions, Aro $aro)
{
$key = implode('_', ['allowed_role-' . $aro->get('id'), 'user-' . $this->_user->get('id', Role::PUBLIC_ID), 'acos-' . implode('-', array_keys($actions->toArray()))]);
if (!Configure::read('debug')) {
return md5($key);
}
return $key;
}