本文整理汇总了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);
}