本文整理汇总了PHP中Contact::getTableName方法的典型用法代码示例。如果您正苦于以下问题:PHP Contact::getTableName方法的具体用法?PHP Contact::getTableName怎么用?PHP Contact::getTableName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contact
的用法示例。
在下文中一共展示了Contact::getTableName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$super = SecurityTestHelper::createSuperAdmin();
Yii::app()->user->userModel = $super;
$accountTableName = Account::getTableName();
$contactTableName = Contact::getTableName();
$opportunityTableName = Opportunity::getTableName();
ExternalSystemIdUtil::addExternalIdColumnIfMissing($accountTableName);
ExternalSystemIdUtil::addExternalIdColumnIfMissing($contactTableName);
ExternalSystemIdUtil::addExternalIdColumnIfMissing($opportunityTableName);
}
示例2: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$super = SecurityTestHelper::createSuperAdmin();
Yii::app()->user->userModel = $super;
$accountTableName = Account::getTableName('Account');
$contactTableName = Contact::getTableName('Contact');
$opportunityTableName = Opportunity::getTableName('Opportunity');
$columnName = ExternalSystemIdUtil::EXTERNAL_SYSTEM_ID_COLUMN_NAME;
RedBeanColumnTypeOptimizer::externalIdColumn($accountTableName, $columnName);
RedBeanColumnTypeOptimizer::externalIdColumn($contactTableName, $columnName);
RedBeanColumnTypeOptimizer::externalIdColumn($opportunityTableName, $columnName);
}
示例3: testImportDataAnalysisResults
public function testImportDataAnalysisResults()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$import = new Import();
$serializedData['importRulesType'] = 'Tasks';
$import->serializedData = serialize($serializedData);
$this->assertTrue($import->save());
$accountTableName = Account::getTableName('Account');
$contactTableName = Contact::getTableName('Contact');
$opportunityTableName = Opportunity::getTableName('Opportunity');
$account1 = AccountTestHelper::createAccountByNameForOwner('account1', $super);
$account2 = AccountTestHelper::createAccountByNameForOwner('account2', $super);
$account3 = AccountTestHelper::createAccountByNameForOwner('account3', $super);
$contact1 = ContactTestHelper::createContactByNameForOwner('contact1', $super);
$contact2 = ContactTestHelper::createContactByNameForOwner('contact2', $super);
$contact3 = ContactTestHelper::createContactByNameForOwner('contact3', $super);
$opportunity1 = OpportunityTestHelper::createOpportunityByNameForOwner('opportunity1', $super);
$opportunity2 = OpportunityTestHelper::createOpportunityByNameForOwner('opportunity2', $super);
$opportunity3 = OpportunityTestHelper::createOpportunityByNameForOwner('opportunity3', $super);
//Make models externally linked for testing.
ImportTestHelper::updateModelsExternalId($account2, 'ACC');
ImportTestHelper::updateModelsExternalId($contact2, 'CON');
ImportTestHelper::updateModelsExternalId($opportunity2, 'OPP');
ImportTestHelper::createTempTableByFileNameAndTableName('importAnalyzerTest.csv', $import->getTempTableName(), Yii::getPathOfAlias('application.modules.tasks.tests.unit.files'));
R::exec("update " . $import->getTempTableName() . " set column_0 = " . $account3->id . " where id != 1 limit 3");
R::exec("update " . $import->getTempTableName() . " set column_2 = " . $contact3->id . " where id != 1 limit 4");
R::exec("update " . $import->getTempTableName() . " set column_4 = " . $opportunity3->id . " where id != 1 limit 5");
$mappingData = array('column_0' => ImportMappingUtil::makeModelDerivedColumnMappingData('AccountDerived', IdValueTypeMappingRuleForm::ZURMO_MODEL_ID), 'column_1' => ImportMappingUtil::makeModelDerivedColumnMappingData('AccountDerived'), 'column_2' => ImportMappingUtil::makeModelDerivedColumnMappingData('ContactDerived', IdValueTypeMappingRuleForm::ZURMO_MODEL_ID), 'column_3' => ImportMappingUtil::makeModelDerivedColumnMappingData('ContactDerived'), 'column_4' => ImportMappingUtil::makeModelDerivedColumnMappingData('OpportunityDerived', IdValueTypeMappingRuleForm::ZURMO_MODEL_ID), 'column_5' => ImportMappingUtil::makeModelDerivedColumnMappingData('OpportunityDerived'));
$serializedData = unserialize($import->serializedData);
$serializedData['mappingData'] = $mappingData;
$import->serializedData = serialize($serializedData);
$this->assertTrue($import->save());
$importRules = ImportRulesUtil::makeImportRulesByType('Tasks');
$config = array('pagination' => array('pageSize' => 2));
//This test csv has a header row.
$dataProvider = new ImportDataProvider($import->getTempTableName(), true, $config);
//Run data analyzer
$importDataAnalyzer = new ImportDataAnalyzer($importRules, $dataProvider);
foreach ($mappingData as $columnName => $columnMappingData) {
$importDataAnalyzer->analyzeByColumnNameAndColumnMappingData($columnName, $columnMappingData);
}
$messagesData = $importDataAnalyzer->getMessagesData();
$compareData = array('column_0' => array(array('message' => '3 record(s) will be updated and 7 record(s) will be skipped during import.', 'sanitizerUtilType' => 'AccountDerivedIdValueType', 'moreAvailable' => false)), 'column_1' => array(array('message' => '3 record(s) will be updated and 7 record(s) will be skipped during import.', 'sanitizerUtilType' => 'AccountDerivedIdValueType', 'moreAvailable' => false)), 'column_2' => array(array('message' => '4 record(s) will be updated and 6 record(s) will be skipped during import.', 'sanitizerUtilType' => 'ContactDerivedIdValueType', 'moreAvailable' => false)), 'column_3' => array(array('message' => '3 record(s) will be updated and 7 record(s) will be skipped during import.', 'sanitizerUtilType' => 'ContactDerivedIdValueType', 'moreAvailable' => false)), 'column_4' => array(array('message' => '5 record(s) will be updated and 5 record(s) will be skipped during import.', 'sanitizerUtilType' => 'OpportunityDerivedIdValueType', 'moreAvailable' => false)), 'column_5' => array(array('message' => '3 record(s) will be updated and 7 record(s) will be skipped during import.', 'sanitizerUtilType' => 'OpportunityDerivedIdValueType', 'moreAvailable' => false)));
$this->assertEquals($compareData, $messagesData);
$importInstructionsData = $importDataAnalyzer->getImportInstructionsData();
$compareInstructionsData = array();
$this->assertEquals($compareInstructionsData, $importInstructionsData);
}
示例4: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$super = SecurityTestHelper::createSuperAdmin();
Yii::app()->user->userModel = $super;
ExternalSystemIdUtil::addExternalIdColumnIfMissing(Account::getTableName());
ExternalSystemIdUtil::addExternalIdColumnIfMissing(Contact::getTableName());
ExternalSystemIdUtil::addExternalIdColumnIfMissing(Opportunity::getTableName());
$account = AccountTestHelper::createAccountByNameForOwner('testAccount', $super);
ImportTestHelper::updateModelsExternalId($account, 'ACC');
$contact = ContactTestHelper::createContactByNameForOwner('testContact', $super);
ImportTestHelper::updateModelsExternalId($contact, 'CON');
$opportunity = OpportunityTestHelper::createOpportunityByNameForOwner('testOpportunity', $super);
ImportTestHelper::updateModelsExternalId($opportunity, 'OPP');
}
示例5: testCreateTableSQLParams
public function testCreateTableSQLParams()
{
$bean = new Contact();
$sql = $this->_helper->createTableSQLParams($bean->getTableName(), $bean->getFieldDefinitions(), $bean->getIndices());
$this->assertRegExp('/create\\s*table\\s*contacts/i', $sql);
}
示例6: testImportSwitchingOwnerButShouldStillCreate
/**
* Test when a normal user who can only view records he owns, tries to import records assigned to another user.
*/
public function testImportSwitchingOwnerButShouldStillCreate()
{
$super = User::getByUsername('super');
$jim = User::getByUsername('jim');
Yii::app()->user->userModel = $jim;
//Confirm Jim can can only view ImportModelTestItems he owns.
$item = NamedSecurableItem::getByName('ContactsModule');
$this->assertEquals(Permission::NONE, $item->getEffectivePermissions($jim));
$testModels = Contact::getAll();
$this->assertEquals(0, count($testModels));
$import = new Import();
$serializedData['importRulesType'] = 'Contacts';
$serializedData['firstRowIsHeaderRow'] = true;
$import->serializedData = serialize($serializedData);
$this->assertTrue($import->save());
ImportTestHelper::createTempTableByFileNameAndTableName('importTest.csv', $import->getTempTableName(), Yii::getPathOfAlias('application.modules.contacts.tests.unit.files'));
$this->assertEquals(4, ImportDatabaseUtil::getCount($import->getTempTableName()));
// includes header rows.
$ownerColumnMappingData = array('attributeIndexOrDerivedType' => 'owner', 'type' => 'extraColumn', 'mappingRulesData' => array('DefaultModelNameIdMappingRuleForm' => array('defaultModelId' => $super->id), 'UserValueTypeModelAttributeMappingRuleForm' => array('type' => UserValueTypeModelAttributeMappingRuleForm::ZURMO_USER_ID)));
$startingStateId = ContactsUtil::getStartingState()->id;
$mappingData = array('column_0' => ImportMappingUtil::makeStringColumnMappingData('firstName'), 'column_1' => ImportMappingUtil::makeStringColumnMappingData('lastName'), 'column_2' => $ownerColumnMappingData, 'column_3' => ContactImportTestHelper::makeStateColumnMappingData($startingStateId, 'extraColumn'));
$importRules = ImportRulesUtil::makeImportRulesByType('Contacts');
$page = 0;
$config = array('pagination' => array('pageSize' => 50));
//This way all rows are processed.
$dataProvider = new ImportDataProvider($import->getTempTableName(), true, $config);
$dataProvider->getPagination()->setCurrentPage($page);
$importResultsUtil = new ImportResultsUtil($import);
$messageLogger = new ImportMessageLogger();
ImportUtil::importByDataProvider($dataProvider, $importRules, $mappingData, $importResultsUtil, new ExplicitReadWriteModelPermissions(), $messageLogger);
$importResultsUtil->processStatusAndMessagesForEachRow();
//3 models are created, but Jim can't see them since they are assigned to someone else.
$testModels = Contact::getAll();
$this->assertEquals(0, count($testModels));
//Using super, should see all 3 models created.
Yii::app()->user->userModel = $super;
$testModels = Contact::getAll();
$this->assertEquals(3, count($testModels));
foreach ($testModels as $model) {
$this->assertEquals(array(Permission::NONE, Permission::NONE), $model->getExplicitActualPermissions($jim));
}
//Confirm 4 rows were processed as 'created'.
$this->assertEquals(3, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::CREATED));
//Confirm that 0 rows were processed as 'updated'.
$this->assertEquals(0, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::UPDATED));
//Confirm 0 rows were processed as 'errors'.
$this->assertEquals(0, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::ERROR));
$beansWithErrors = ImportDatabaseUtil::getSubset($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::ERROR);
$this->assertEquals(0, count($beansWithErrors));
//Clear out data in table
R::exec("delete from " . Contact::getTableName('Contact'));
}
示例7: updateUserIdOnUserDelete
/**
* Set user_id to 0 for all users that that previously were associated with a recently deleted user
*
*/
function updateUserIdOnUserDelete($user_id)
{
if (!is_numeric($user_id)) {
return false;
}
$c = new Contact();
$name = $c->getTableName(true);
$sql = "UPDATE " . $name . " SET user_id = 0 WHERE user_id = " . $user_id;
return DB::execute($sql);
}