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


PHP Portfolio::findById方法代码示例

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


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

示例1: testSaveHabtmNoPrimaryData

 /**
  * testSaveHabtmNoPrimaryData method
  *
  * @return void
  */
 public function testSaveHabtmNoPrimaryData()
 {
     $this->loadFixtures('Article', 'User', 'Comment', 'Tag', 'ArticlesTag');
     $TestModel = new Article();
     $TestModel->unbindModel(array('belongsTo' => array('User'), 'hasMany' => array('Comment')), false);
     $result = $TestModel->findById(2);
     $expected = array('Article' => array('id' => '2', 'user_id' => '3', 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31'), 'Tag' => array(array('id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'), array('id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31')));
     $this->assertEquals($expected, $result);
     $TestModel->id = 2;
     $data = array('Tag' => array('Tag' => array(2)));
     $result = $TestModel->save($data);
     $this->assertEquals($data['Tag'], $result['Tag']);
     $result = $TestModel->findById(2);
     $expected = array('Article' => array('id' => '2', 'user_id' => '3', 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => self::date()), 'Tag' => array(array('id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31')));
     $this->assertEquals($expected, $result);
     $this->loadFixtures('Portfolio', 'Item', 'ItemsPortfolio');
     $TestModel = new Portfolio();
     $result = $TestModel->findById(2);
     $expected = array('Portfolio' => array('id' => 2, 'seller_id' => 1, 'name' => 'Portfolio 2'), 'Item' => array(array('id' => 2, 'syfile_id' => 2, 'published' => '', 'name' => 'Item 2', 'ItemsPortfolio' => array('id' => 2, 'item_id' => 2, 'portfolio_id' => 2)), array('id' => 6, 'syfile_id' => 6, 'published' => '', 'name' => 'Item 6', 'ItemsPortfolio' => array('id' => 6, 'item_id' => 6, 'portfolio_id' => 2))));
     $this->assertEquals($expected, $result);
     $data = array('Item' => array('Item' => array(1, 2)));
     $TestModel->id = 2;
     $TestModel->save($data);
     $result = $TestModel->findById(2);
     $result['Item'] = Hash::sort($result['Item'], '{n}.id', 'asc');
     $expected = array('Portfolio' => array('id' => 2, 'seller_id' => 1, 'name' => 'Portfolio 2'), 'Item' => array(array('id' => 1, 'syfile_id' => 1, 'published' => '', 'name' => 'Item 1', 'ItemsPortfolio' => array('id' => 7, 'item_id' => 1, 'portfolio_id' => 2)), array('id' => 2, 'syfile_id' => 2, 'published' => '', 'name' => 'Item 2', 'ItemsPortfolio' => array('id' => 8, 'item_id' => 2, 'portfolio_id' => 2))));
     $this->assertEquals($expected, $result);
 }
开发者ID:manzapanza,项目名称:cakephp-api-utils,代码行数:33,代码来源:ModelWriteTest.php


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