本文整理汇总了PHP中CContact::overrideDatabase方法的典型用法代码示例。如果您正苦于以下问题:PHP CContact::overrideDatabase方法的具体用法?PHP CContact::overrideDatabase怎么用?PHP CContact::overrideDatabase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CContact
的用法示例。
在下文中一共展示了CContact::overrideDatabase方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testStoreCreate
/**
* Tests the proper creation of a user & contact
*/
public function testStoreCreate()
{
$this->obj->bind($this->post_data);
$result = $this->obj->store();
$contact = new CContact();
$contact->overrideDatabase($this->mockDB);
$contact->bind($this->post_data);
$result = $contact->store();
$this->assertTrue($result);
$this->assertNotEquals(0, $contact->contact_id);
$this->obj->user_contact = $contact->contact_id;
$result = $this->obj->store();
$this->assertTrue($result);
$this->assertNotEquals(0, $this->obj->user_id);
}
示例2: testLoad
public function testLoad()
{
$this->obj->bind($this->post_data);
$result = $this->obj->store();
$this->assertTrue($result);
$item = new CContact();
$item->overrideDatabase($this->mockDB);
$this->post_data['contact_id'] = $this->obj->contact_id;
$this->mockDB->stageHash($this->post_data);
$item->load($this->obj->contact_id);
$this->assertEquals($this->obj->contact_first_name, $item->contact_first_name);
$this->assertEquals($this->obj->contact_last_name, $item->contact_last_name);
$this->assertEquals($this->obj->contact_display_name, $item->contact_display_name);
$this->assertEquals($this->obj->contact_company, $item->contact_company);
$this->assertEquals($this->obj->contact_department, $item->contact_department);
$this->assertEquals($this->obj->contact_icon, $item->contact_icon);
$this->assertEquals($this->obj->contact_owner, $item->contact_owner);
$this->assertEquals($this->obj->contact_id, $item->contact_id);
}
示例3: hook_cron
public function hook_cron()
{
$q = $this->_getQuery();
$q->addTable('contacts');
$q->addQuery('contact_id');
$q->addWhere('contact_display_name IS NULL OR contact_display_name = ""');
$contactIdList = $q->loadList();
foreach ($contactIdList as $contactId) {
$myContact = new CContact();
$myContact->overrideDatabase($this->_query);
$myContact = $myContact->load($contactId['contact_id']);
$myContact->store();
}
//To Bruce: Clean updatekeys based on datediff to warn about long waiting.
//TODO: This should be converted to a system configuration value
$days_for_update = 5;
$this->clearOldUpdatekeys($days_for_update);
}
示例4: testDelete
public function testDelete()
{
$this->obj->bind($this->post_data);
$result = $this->obj->store();
$this->assertTrue($result);
$original_id = $this->obj->contact_id;
$result = $this->obj->delete();
$item = new CContact();
$item->overrideDatabase($this->mockDB);
$this->mockDB->stageHash(array('contact_first_name' => '', 'contact_display_name' => ''));
$item->load($original_id);
$this->assertTrue(is_a($item, 'CContact'));
$this->assertEquals('', $item->contact_first_name);
$this->assertEquals('', $item->contact_display_name);
}