當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Restaurant::unbindModel方法代碼示例

本文整理匯總了PHP中Restaurant::unbindModel方法的典型用法代碼示例。如果您正苦於以下問題:PHP Restaurant::unbindModel方法的具體用法?PHP Restaurant::unbindModel怎麽用?PHP Restaurant::unbindModel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Restaurant的用法示例。


在下文中一共展示了Restaurant::unbindModel方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testBehaviorBelongsToFindCallbacks

 /**
  * testBehaviorBelongsToFindCallbacks method
  *
  * @return void
  */
 public function testBehaviorBelongsToFindCallbacks()
 {
     $this->skipIf($this->db instanceof Sqlserver, 'This test is not compatible with SQL Server.');
     $conditions = array('order' => 'Apple.id ASC');
     $Apple = new Restaurant();
     $Apple->unbindModel(array('hasMany' => array('Child'), 'hasOne' => array('Sample')), false);
     $expected = $Apple->find('all', $conditions);
     $Apple->unbindModel(array('belongsTo' => array('Parent')));
     $wellBehaved = $Apple->find('all', $conditions);
     $Apple->Parent->Behaviors->load('Test');
     $Apple->unbindModel(array('belongsTo' => array('Parent')));
     $this->assertSame($Apple->find('all', $conditions), $wellBehaved);
     $Apple->Parent->Behaviors->load('Test', array('before' => 'off'));
     $this->assertSame($expected, $Apple->find('all', $conditions));
     $Apple->Parent->Behaviors->load('Test', array('before' => 'test'));
     $this->assertSame($expected, $Apple->find('all', $conditions));
     $Apple->Parent->Behaviors->load('Test', array('before' => 'modify'));
     $expected2 = array(array('Apple' => array('id' => 1), 'Parent' => array('id' => 2, 'name' => 'Bright Red Apple', 'mytime' => '22:57:17')), array('Apple' => array('id' => 2), 'Parent' => array('id' => 1, 'name' => 'Red Apple 1', 'mytime' => '22:57:17')), array('Apple' => array('id' => 3), 'Parent' => array('id' => 2, 'name' => 'Bright Red Apple', 'mytime' => '22:57:17')));
     $result2 = $Apple->find('all', array('fields' => array('Apple.id', 'Parent.id', 'Parent.name', 'Parent.mytime'), 'conditions' => array('Apple.id <' => '4'), 'order' => 'Apple.id ASC'));
     $this->assertEquals($expected2, $result2);
     $Apple->Parent->Behaviors->disable('Test');
     $result = $Apple->find('all', $conditions);
     $this->assertEquals($expected, $result);
     $Apple->Parent->Behaviors->load('Test', array('after' => 'off'));
     $this->assertEquals($expected, $Apple->find('all', $conditions));
     $Apple->Parent->Behaviors->load('Test', array('after' => 'test'));
     $this->assertEquals($expected, $Apple->find('all', $conditions));
     $Apple->Parent->Behaviors->load('Test', array('after' => 'test2'));
     $this->assertEquals($expected, $Apple->find('all', $conditions));
 }
開發者ID:nogikko,項目名稱:yumyum,代碼行數:35,代碼來源:BehaviorCollectionTest.php


注:本文中的Restaurant::unbindModel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。