本文整理汇总了PHP中ZurmoRedBean::exec方法的典型用法代码示例。如果您正苦于以下问题:PHP ZurmoRedBean::exec方法的具体用法?PHP ZurmoRedBean::exec怎么用?PHP ZurmoRedBean::exec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZurmoRedBean
的用法示例。
在下文中一共展示了ZurmoRedBean::exec方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRun
public function testRun()
{
$quote = DatabaseCompatibilityUtil::getQuote();
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
$folder = EmailFolder::getByBoxAndType($box, EmailFolder::TYPE_SENT);
//Create 2 sent notifications, and set one with a date over a week ago (8 days ago) for the modifiedDateTime
$emailMessage = EmailMessageTestHelper::createDraftSystemEmail('My Email Message', $super);
$emailMessage->folder = $folder;
$saved = $emailMessage->save();
$this->assertTrue($saved);
$modifiedDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 60 * 60 * 24 * 8);
$sql = "Update item set modifieddatetime = '" . $modifiedDateTime . "' where id = " . $emailMessage->getClassId('Item');
ZurmoRedBean::exec($sql);
$emailMessage2 = EmailMessageTestHelper::createDraftSystemEmail('My Email Message 2', $super);
$emailMessage2->folder = $folder;
$saved = $emailMessage2->save();
$this->assertTrue($saved);
$this->assertEquals(2, EmailMessage::getCount());
$job = new ClearSentNotificationsEmailJob();
$this->assertTrue($job->run());
$emailMessages = EmailMessage::getAll();
$this->assertEquals(1, count($emailMessages));
$this->assertEquals($emailMessage2->id, $emailMessages[0]->id);
}
示例2: testRun
public function testRun()
{
$quote = DatabaseCompatibilityUtil::getQuote();
//Create 2 imports, and set one with a date over a week ago (8 days ago) for the modifiedDateTime
$import = new Import();
$serializedData['importRulesType'] = 'ImportModelTestItem';
$import->serializedData = serialize($serializedData);
$this->assertTrue($import->save());
ImportTestHelper::createTempTableByFileNameAndTableName('importAnalyzerTest.csv', $import->getTempTableName(), true);
$modifiedDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 60 * 60 * 24 * 8);
$sql = "Update item set modifieddatetime = '" . $modifiedDateTime . "' where id = " . $import->getClassId('Item');
ZurmoRedBean::exec($sql);
$staleImportId = $import->id;
$import2 = new Import();
$serializedData['importRulesType'] = 'ImportModelTestItem';
$import2->serializedData = serialize($serializedData);
$this->assertTrue($import2->save());
ImportTestHelper::createTempTableByFileNameAndTableName('importAnalyzerTest.csv', $import2->getTempTableName(), true);
$this->assertEquals(2, Import::getCount());
$tableExists = ZurmoRedBean::$writer->doesTableExist($import->getTempTableName());
$this->assertTrue($tableExists);
$job = new ImportCleanupJob();
$this->assertTrue($job->run());
$tableExists = ZurmoRedBean::$writer->doesTableExist($import->getTempTableName());
$this->assertFalse($tableExists);
$imports = Import::getAll();
$this->assertEquals(1, count($imports));
$this->assertEquals($import2->id, $imports[0]->id);
}
示例3: run
/**
* Deletes all job logs where the modifiedDateTime was more than 1 week ago.
* Runs operation in bulk to improve performance when large jobLogs are present.
*
* @see BaseJob::run()
*/
public function run()
{
$oneWeekAgoTimeStamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 60 * 60 * 24 * 7);
$sql = 'DELETE from item, joblog using joblog inner join item on ' . 'item.id = joblog.item_id where joblog.enddatetime <= "' . $oneWeekAgoTimeStamp . '"';
ZurmoRedBean::exec($sql);
return true;
}
示例4: deleteConversationItems
/**
* Given a event, perform the deletion of conversationItems related to the event sender.
* @param CEvent $event
*/
public function deleteConversationItems(CEvent $event)
{
$model = $event->sender;
assert('$model instanceof Item');
$itemId = $model->getClassId('Item');
$sql = 'DELETE from conversation_item where item_id = ' . $itemId;
ZurmoRedBean::exec($sql);
}
示例5: cacheEntry
public static function cacheEntry($identifier, $entry)
{
assert('is_string($entry) || is_numeric($entry)');
parent::cacheEntry($identifier, $entry);
if (static::supportsAndAllowsDatabaseCaching()) {
ZurmoRedBean::exec("insert into actual_rights_cache\n (identifier, entry) values ('" . $identifier . "', '" . $entry . "') on duplicate key\n update entry = " . $entry);
}
}
示例6: updateByModel
/**
* Given a model and external system id, update the external system id in the database for that model
* @param object $model
* @param string $externalSystemId
*/
public static function updateByModel(RedBeanModel $model, $externalSystemId)
{
assert('$externalSystemId == null || is_string($externalSystemId)');
$columnName = self::EXTERNAL_SYSTEM_ID_COLUMN_NAME;
$tableName = $model::getTableName();
static::addExternalIdColumnIfMissing($tableName);
ZurmoRedBean::exec("update " . $tableName . " set {$columnName} = '" . $externalSystemId . "' where id = " . $model->id);
}
示例7: addTransactionResolvedForOptimization
public static function addTransactionResolvedForOptimization($gamePoint, $value)
{
$transaction = new GamePointTransaction();
$transaction->value = $value;
$transaction->unrestrictedSave();
$tableName = GamePointTransaction::getTableName();
$sql = "UPDATE {$tableName} SET gamepoint_id = '" . $gamePoint->id . "'\n WHERE id = '" . $transaction->id . "'";
ZurmoRedBean::exec($sql);
}
示例8: deletePersonsOrAccountsItems
/**
* Given a event, perform the deletion of conversationItems related to the event sender.
* @param CEvent $event
*/
public function deletePersonsOrAccountsItems(CEvent $event)
{
$model = $event->sender;
assert('$model instanceof Item');
$itemId = $model->getClassId('Item');
$sql = 'DELETE from emailmessagerecipient_item where item_id = ' . $itemId;
ZurmoRedBean::exec($sql);
$sql = 'DELETE from emailmessagesender_item where item_id = ' . $itemId;
ZurmoRedBean::exec($sql);
}
示例9: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$super = SecurityTestHelper::createSuperAdmin();
SecurityTestHelper::createUsers();
$account = AccountTestHelper::createAccountByNameForOwner('anAccount2', Yii::app()->user->userModel);
$task = TaskTestHelper::createTaskWithOwnerAndRelatedAccount('startTask', $super, $account);
$task->delete();
ZurmoRedBean::exec('delete from activity_item');
}
示例10: testRun
public function testRun()
{
$quote = DatabaseCompatibilityUtil::getQuote();
//Create 2 export items, and set one with a date over a week ago (8 days ago) for the modifiedDateTime
$exportItem = new ExportItem();
$exportItem->isCompleted = 0;
$exportItem->exportFileType = 'csv';
$exportItem->exportFileName = 'test';
$exportItem->modelClassName = 'Account';
$exportItem->serializedData = serialize(array('test', 'test2'));
$this->assertTrue($exportItem->save());
$fileContent = new FileContent();
$fileContent->content = 'test';
$exportFileModel = new ExportFileModel();
$exportFileModel->fileContent = $fileContent;
$exportFileModel->name = $exportItem->exportFileName . ".csv";
$exportFileModel->type = 'application/octet-stream';
$exportFileModel->size = strlen($fileContent->content);
$this->assertTrue($exportFileModel->save());
$exportFileModel1Id = $exportFileModel->id;
$exportItem->exportFileModel = $exportFileModel;
$this->assertTrue($exportItem->save());
$modifiedDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 60 * 60 * 24 * 8);
$sql = "Update item set modifieddatetime = '" . $modifiedDateTime . "' where id = " . $exportItem->getClassId('Item');
ZurmoRedBean::exec($sql);
// Second exportItem, that shouldn't be deleted.
$exportItem2 = new ExportItem();
$exportItem2->isCompleted = 0;
$exportItem2->exportFileType = 'csv';
$exportItem2->exportFileName = 'test';
$exportItem2->modelClassName = 'Account';
$exportItem2->serializedData = serialize(array('test', 'test2'));
$this->assertTrue($exportItem2->save());
$fileContent2 = new FileContent();
$fileContent2->content = 'test';
$exportFileModel2 = new ExportFileModel();
$exportFileModel2->fileContent = $fileContent2;
$exportFileModel2->name = $exportItem->exportFileName . ".csv";
$exportFileModel2->type = 'application/octet-stream';
$exportFileModel2->size = strlen($fileContent->content);
$this->assertTrue($exportFileModel2->save());
$exportFileModel2Id = $exportFileModel2->id;
$exportItem2->exportFileModel = $exportFileModel2;
$this->assertTrue($exportItem2->save());
$job = new ExportCleanupJob();
$this->assertTrue($job->run());
$exportItems = ExportItem::getAll();
$this->assertEquals(1, count($exportItems));
$this->assertEquals($exportItem2->id, $exportItems[0]->id);
}
示例11: testSimpleUserImportWhereAllRowsSucceed
public function testSimpleUserImportWhereAllRowsSucceed()
{
Yii::app()->user->userModel = User::getByUsername('super');
$account = AccountTestHelper::createAccountByNameForOwner('Account', Yii::app()->user->userModel);
$contact = ContactTestHelper::createContactByNameForOwner('Contact', Yii::app()->user->userModel);
$accountContactAffiliations = AccountContactAffiliation::getAll();
$this->assertEquals(0, count($accountContactAffiliations));
$import = new Import();
$serializedData['importRulesType'] = 'AccountContactAffiliations';
$serializedData['firstRowIsHeaderRow'] = true;
$import->serializedData = serialize($serializedData);
$this->assertTrue($import->save());
ImportTestHelper::createTempTableByFileNameAndTableName('importTest.csv', $import->getTempTableName(), true, Yii::getPathOfAlias('application.modules.accountContactAffiliations.tests.unit.files'));
//update the ids of the account column to match the parent account.
ZurmoRedBean::exec("update " . $import->getTempTableName() . " set column_2 = " . $account->id . " where id != 1 limit 4");
ZurmoRedBean::exec("update " . $import->getTempTableName() . " set column_1 = " . $contact->id . " where id != 1 limit 4");
$this->assertEquals(4, ImportDatabaseUtil::getCount($import->getTempTableName()));
// includes header rows.
$mappingData = array('column_0' => ImportMappingUtil::makeDropDownColumnMappingData('role'), 'column_1' => ImportMappingUtil::makeHasOneColumnMappingData('contact'), 'column_2' => ImportMappingUtil::makeHasOneColumnMappingData('account'));
$importRules = ImportRulesUtil::makeImportRulesByType('AccountContactAffiliations');
$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();
//Confirm that 3 models where created.
$accountContactAffiliations = AccountContactAffiliation::getAll();
$this->assertEquals(3, count($accountContactAffiliations));
$this->assertEquals('0', $accountContactAffiliations[0]->primary);
$this->assertTrue($accountContactAffiliations[0]->account->isSame($account));
$this->assertTrue($accountContactAffiliations[0]->contact->isSame($contact));
$this->assertEquals('', $accountContactAffiliations[0]->role->value);
$this->assertEquals('0', $accountContactAffiliations[1]->primary);
$this->assertTrue($accountContactAffiliations[1]->account->isSame($account));
$this->assertTrue($accountContactAffiliations[1]->contact->isSame($contact));
$this->assertEquals('Support', $accountContactAffiliations[1]->role->value);
$this->assertEquals('0', $accountContactAffiliations[2]->primary);
$this->assertTrue($accountContactAffiliations[2]->account->isSame($account));
$this->assertTrue($accountContactAffiliations[2]->contact->isSame($contact));
$this->assertEquals('Technical', $accountContactAffiliations[2]->role->value);
//Confirm 3 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));
}
示例12: updateValueByDataIdAndOldValueAndNewValue
public static function updateValueByDataIdAndOldValueAndNewValue($customFieldDataId, $oldValue, $newValue)
{
$quote = DatabaseCompatibilityUtil::getQuote();
$customFieldTableName = CustomField::getTableName();
$baseCustomFieldTableName = BaseCustomField::getTableName();
$baseCustomFieldJoinColumnName = $baseCustomFieldTableName . '_id';
$valueAttributeColumnName = 'value';
$dataAttributeColumnName = static::getForeignKeyName('BaseCustomField', 'data');
$sql = "update {$quote}{$customFieldTableName}{$quote}, {$quote}{$baseCustomFieldTableName}{$quote} ";
$sql .= "set {$quote}{$valueAttributeColumnName}{$quote} = '{$newValue}' ";
$sql .= "where {$quote}{$customFieldTableName}{$quote}.{$baseCustomFieldJoinColumnName} = ";
// Not Coding Standard
$sql .= "{$quote}{$baseCustomFieldTableName}{$quote}.id ";
$sql .= "AND {$quote}{$dataAttributeColumnName}{$quote} = {$customFieldDataId} ";
$sql .= "AND {$quote}{$valueAttributeColumnName}{$quote} = '{$oldValue}'";
ZurmoRedBean::exec($sql);
}
示例13: testGetDataFilteredByStatus
/**
* @depends testGetData
*/
public function testGetDataFilteredByStatus()
{
$testTableName = 'testimporttable';
ImportTestHelper::createTempTableByFileNameAndTableName('importTest.csv', $testTableName, true);
$config = array('pagination' => array('pageSize' => 99));
$dataProvider = new ImportDataProvider($testTableName, true, $config);
$data = $dataProvider->getData();
$this->assertEquals(4, count($data));
ZurmoRedBean::exec("update " . $testTableName . " set status = " . ImportRowDataResultsUtil::ERROR . " where id != 1 limit 1");
//Filter by error status.
$dataProvider = new ImportDataProvider($testTableName, true, $config, ImportRowDataResultsUtil::ERROR);
$data = $dataProvider->getData();
$this->assertEquals(1, count($data));
//Do without a filter
$dataProvider = new ImportDataProvider($testTableName, true, $config);
$data = $dataProvider->getData();
$this->assertEquals(4, count($data));
}
示例14: testRebuilt
public function testRebuilt()
{
ModelCreationApiSyncUtil::buildTable();
$sql = 'INSERT INTO ' . ModelCreationApiSyncUtil::TABLE_NAME . ' VALUES (null, \'ApiServiceName\', \'1\', \'Contact\', \'2013-05-03 15:16:06\')';
ZurmoRedBean::exec($sql);
$apiServiceCreationRow = ZurmoRedBean::getRow('SELECT * FROM ' . ModelCreationApiSyncUtil::TABLE_NAME);
$this->assertTrue($apiServiceCreationRow['id'] > 0);
$this->assertEquals('ApiServiceName', $apiServiceCreationRow['servicename']);
$this->assertEquals(1, $apiServiceCreationRow['modelid']);
$this->assertEquals('Contact', $apiServiceCreationRow['modelclassname']);
$this->assertEquals('2013-05-03 15:16:06', $apiServiceCreationRow['createddatetime']);
// Now test when table already exist
ModelCreationApiSyncUtil::buildTable();
$apiServiceCreationRow = ZurmoRedBean::getRow('SELECT COUNT(*) as totalRows FROM ' . ModelCreationApiSyncUtil::TABLE_NAME);
$this->assertEquals(1, $apiServiceCreationRow['totalRows']);
$sql = 'INSERT INTO ' . ModelCreationApiSyncUtil::TABLE_NAME . ' VALUES (null, \'ApiServiceName\', \'2\', \'Contact\', \'2013-06-03 15:16:06\')';
ZurmoRedBean::exec($sql);
$apiServiceCreationRow = ZurmoRedBean::getRow('SELECT COUNT(*) as totalRows FROM ' . ModelCreationApiSyncUtil::TABLE_NAME);
$this->assertEquals(2, $apiServiceCreationRow['totalRows']);
}
示例15: testRunDiagnostic
public function testRunDiagnostic()
{
ZurmoRedBean::exec("SHOW TABLES");
$countBefore = ZurmoRedBean::getCell("SELECT FOUND_ROWS();");
$content = $this->runControllerWithNoExceptionsAndGetContent('configuration/default/runDiagnostic');
$this->assertContains("Failed Required Services", $content);
$this->assertContains("<span class=\"fail\">FAIL</span>", $content);
$this->assertContains("Zurmo runs only on Apache 2.2.1 and higher or Microsoft-IIS 5.0.0 or higher web servers.", $content);
$this->assertContains("\$_SERVER does not have HTTP_HOST, SERVER_NAME, SERVER_PORT, HTTP_ACCEPT, HTTP_USER_AGENT", $content);
$criticalFailureCount = substr_count($content, "<span class=\"fail\">FAIL</span>");
$this->assertThat(true, $this->logicalOr($this->equalTo(2, $criticalFailureCount), $this->equalTo(3, $criticalFailureCount)));
if ($criticalFailureCount === 3) {
$this->assertTrue(strpos($content, "The application.log runtime file is writable.<br />\n" . "The /minScript/cache runtime directory is not writable.<br />\n" . "The debug.php file is present.") !== false || strpos($content, "Host Info/Script Url is incorrectly configured.") !== false);
}
$this->assertFileExists(realpath(INSTANCE_ROOT . DIRECTORY_SEPARATOR . 'protected' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'perInstance.php'));
$this->assertFileExists(realpath(INSTANCE_ROOT . DIRECTORY_SEPARATOR . 'protected' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'debug.php'));
ZurmoRedBean::exec("SHOW TABLES");
$countAfter = ZurmoRedBean::getCell("SELECT FOUND_ROWS();");
$this->assertEquals($countBefore, $countAfter);
}