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


PHP Hash::nest方法代码示例

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


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

示例1: generateNestedData

 /**
  * Returns nested data set
  * 
  * @param int|null $rootNode Id of top item
  * @return array
  */
 public function generateNestedData($rootId = null)
 {
     $conditions = array();
     $fields = null;
     $order = $this->alias . '.lft ASC';
     $recursive = -1;
     $results = $this->find('all', compact('conditions', 'fields', 'order', 'recursive'));
     return Hash::nest($results, array('root' => $rootId));
 }
开发者ID:fm-labs,项目名称:cakephp-backend,代码行数:15,代码来源:Page.php

示例2: dbFix

 public function dbFix()
 {
     $eTree = Hash::nest($this->Election->children('53c021ec-e11c-49be-b6c8-5c5aacb5b862', false, array('id', 'parent_id', 'name')));
     $elections = array();
     foreach ($eTree as $town) {
         foreach ($town['children'] as $cunli) {
             $elections[$cunli['Election']['id']] = "{$town['Election']['name']} > {$cunli['Election']['name']}";
         }
     }
     $bulletins = $this->Election->Bulletin->find('all', array('conditions' => array('count_elections' => 0, 'name like' => '%雲林縣 > 村里長%')));
     foreach ($bulletins as $bulletin) {
         $bulletinMatched = false;
         foreach ($elections as $electionId => $filter) {
             if (false === $bulletinMatched && false !== strpos($bulletin['Bulletin']['name'], $filter)) {
                 $bulletinMatched = true;
                 if ($this->Election->Bulletin->save(array('Bulletin' => array('id' => $bulletin['Bulletin']['id'], 'count_elections' => 1)))) {
                     $this->Election->save(array('Election' => array('id' => $electionId, 'bulletin_key' => $bulletin['Bulletin']['id'])));
                     $this->Election->BulletinsElection->create();
                     $this->Election->BulletinsElection->save(array('BulletinsElection' => array('Election_id' => $electionId, 'Bulletin_id' => $bulletin['Bulletin']['id'])));
                 }
             }
         }
     }
 }
开发者ID:parker00811,项目名称:elections,代码行数:24,代码来源:BulletinShell.php

示例3: _findThreaded

 /**
  * In the event of ambiguous results returned (multiple top level results, with different parent_ids)
  * top level results with different parent_ids to the first result will be dropped
  *
  * @param string $state
  * @param mixed $query
  * @param array $results
  * @return array Threaded results
  */
 protected function _findThreaded($state, $query, $results = array())
 {
     if ($state === 'before') {
         return $query;
     }
     $parent = 'parent_id';
     if (isset($query['parent'])) {
         $parent = $query['parent'];
     }
     return Hash::nest($results, array('idPath' => '{n}.' . $this->alias . '.' . $this->primaryKey, 'parentPath' => '{n}.' . $this->alias . '.' . $parent));
 }
开发者ID:ajayphp,项目名称:Zuha,代码行数:20,代码来源:Model.php

示例4: testNestInvalid

 /**
  * Tests that nest() throws an InvalidArgumentException when providing an invalid input.
  *
  * @expectedException InvalidArgumentException
  * @return void
  */
 public function testNestInvalid()
 {
     $input = array(array('ParentCategory' => array('id' => '1', 'name' => 'Lorem ipsum dolor sit amet', 'parent_id' => '1')));
     Hash::nest($input);
 }
开发者ID:yuuicchan0912,项目名称:sample1,代码行数:11,代码来源:HashTest.php

示例5: testMissingParent

 /**
  * test Hash nest with no specified parent data.
  *
  * The result should be the same as the input.
  * For an easier comparison, unset all the empty children arrays from the result
  *
  * @return void
  */
 public function testMissingParent()
 {
     $input = array(array('id' => 1), array('id' => 2), array('id' => 3), array('id' => 4), array('id' => 5), array('id' => 6), array('id' => 7), array('id' => 8), array('id' => 9), array('id' => 10));
     $result = Hash::nest($input, array('idPath' => '{n}.id', 'parentPath' => '{n}.parent_id'));
     foreach ($result as &$row) {
         if (empty($row['children'])) {
             unset($row['children']);
         }
     }
     $this->assertEquals($input, $result);
 }
开发者ID:abhinand4858,项目名称:ProgrammedV,代码行数:19,代码来源:HashTest.php

示例6: testNestInvalid

 /**
  * Tests that nest() returns an empty array for invalid input instead of throwing notices.
  *
  * @return void
  */
 public function testNestInvalid()
 {
     $input = array(array('ParentCategory' => array('id' => '1', 'name' => 'Lorem ipsum dolor sit amet', 'parent_id' => '1')));
     $result = Hash::nest($input);
     $this->assertSame(array(), $result);
 }
开发者ID:4Queen,项目名称:php-buildpack,代码行数:11,代码来源:HashTest.php


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