本文整理汇总了PHP中CM_Db_Db::update方法的典型用法代码示例。如果您正苦于以下问题:PHP CM_Db_Db::update方法的具体用法?PHP CM_Db_Db::update怎么用?PHP CM_Db_Db::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CM_Db_Db
的用法示例。
在下文中一共展示了CM_Db_Db::update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setEnabled
/**
* @param bool $state
* @throws CM_Exception
*/
public function setEnabled($state)
{
$state = (bool) $state;
$variationsEnabled = $this->getSplittest()->getVariationsEnabled();
if (!$state && $state != $this->getEnabled() && $variationsEnabled->getCount() <= 1) {
throw new CM_Exception('No variations for Splittest', null, array('messagePublic' => 'At least one variation needs to be enabled'));
}
CM_Db_Db::update('cm_splittestVariation', array('enabled' => $state), array('id' => $this->getId()));
$this->_change();
$variationsEnabled->_change();
}
示例2: testUpdateItemWithJob
public function testUpdateItemWithJob()
{
$query = new CM_Elasticsearch_Query();
$query->queryMatchMulti(array('name'), 'foo');
$source = new CM_PagingSource_Elasticsearch($this->_type, $query);
$this->assertSame(0, $source->getCount());
$id1 = $this->_type->createEntry('foo');
$id2 = $this->_type->createEntry('foo bar');
$this->assertSame(2, $source->getCount());
$this->assertEquals(array($id1, $id2), $source->getItems());
CM_Db_Db::update('index_mock', array('name' => 'bar'), array('id' => $id2));
$this->_type->updateItemWithJob(array('id' => $id2));
$this->assertSame(1, $source->getCount());
$this->assertEquals(array($id1), $source->getItems());
}
示例3: testPaging
public function testPaging()
{
$language = CM_Model_Language::create('Foo', 'foo', true);
$languagePagingAll = $language->getTranslations();
$languagePagingJavascriptOnly = $language->getTranslations(true);
$this->assertEquals([], $languagePagingAll);
$this->assertEquals([], $languagePagingJavascriptOnly);
$languagePagingAll->set('foo', 'foo');
// js
CM_Db_Db::update('cm_model_languagekey', ['javascript' => 1], ['name' => 'foo']);
$languagePagingJavascriptOnly->set('bar', 'bar');
// js
CM_Db_Db::update('cm_model_languagekey', ['javascript' => 1], ['name' => 'bar']);
$languagePagingAll->set('baz', 'baz');
// no js
$this->assertSame('foo', $language->getTranslations()->get('foo'));
$this->assertSame('foo', $language->getTranslations(true)->get('foo'));
$this->assertSame('bar', $language->getTranslations()->get('bar'));
$this->assertSame('bar', $language->getTranslations(true)->get('bar'));
$this->assertSame('baz', $language->getTranslations()->get('baz'));
$exception = $this->catchException(function () use($language) {
$language->getTranslations(true)->get('baz');
});
$this->assertInstanceOf('CM_Exception_Invalid', $exception);
$languagePagingJavascriptOnly->set('foo', 'bar');
$this->assertSame('bar', $language->getTranslations(true)->get('foo'));
$this->assertSame('bar', $language->getTranslations()->get('foo'));
$languagePagingAll->set('bar', 'foo');
$this->assertSame('foo', $language->getTranslations()->get('bar'));
$this->assertSame('foo', $language->getTranslations(true)->get('bar'));
$languagePagingAll->remove('foo');
$this->assertSame(null, $language->getTranslations()->get('foo'));
$this->assertSame(null, $language->getTranslations(true)->get('foo'));
$languagePagingJavascriptOnly->remove('bar');
$this->assertSame(null, $language->getTranslations()->get('bar'));
$this->assertSame(null, $language->getTranslations(true)->get('bar'));
}
示例4: _upgradeCityList
protected function _upgradeCityList()
{
$this->_streamOutput->writeln('Updating cities database…');
$count = $this->_count(array($this->_cityListByRegionRenamed, $this->_cityListByRegionUpdatedCode, $this->_cityListByRegionAdded), 4) + $this->_count($this->_cityListUpdatedRegion, 2);
$item = 0;
foreach ($this->_cityListByRegionRenamed as $cityListByRegionRenamed) {
foreach ($cityListByRegionRenamed as $cityListRenamed) {
foreach ($cityListRenamed as $cityCode => $cityNames) {
$cityName = $cityNames['name'];
CM_Db_Db::update('cm_model_location_city', array('name' => $cityName), array('_maxmind' => $cityCode));
$this->_printProgressCounter(++$item, $count);
}
}
}
unset($this->_cityListByRegionRenamed);
foreach ($this->_cityListByRegionUpdatedCode as $cityListByRegionUpdatedCode) {
foreach ($cityListByRegionUpdatedCode as $cityListUpdatedCode) {
foreach ($cityListUpdatedCode as $cityCode) {
$cityId = $this->_cityIdList[$cityCode];
CM_Db_Db::update('cm_model_location_city', array('_maxmind' => $cityCode), array('id' => $cityId));
$this->_printProgressCounter(++$item, $count);
}
}
}
unset($this->_cityListByRegionUpdatedCode);
foreach ($this->_cityListUpdatedRegion as $countryCode => $cityListUpdatedRegion) {
foreach ($cityListUpdatedRegion as $cityCode => $regionCodes) {
$cityId = $this->_cityIdList[$cityCode];
$regionCode = $regionCodes['regionCode'];
$regionName = $this->_getRegionName($countryCode, $regionCode);
$cityName = $this->_cityListByRegion[$countryCode][$regionCode][$cityCode];
if ($regionName === 'Unknown region') {
CM_Db_Db::update('cm_model_location_city', array('stateId' => null, 'name' => $cityName), array('id' => $cityId));
} else {
$regionId = $this->_regionIdListByCountry[$countryCode][$regionCode];
CM_Db_Db::update('cm_model_location_city', array('stateId' => $regionId, 'name' => $cityName), array('id' => $cityId));
}
$this->_printProgressCounter(++$item, $count);
}
}
unset($this->_regionListByCountry);
unset($this->_cityListByRegion);
unset($this->_cityListUpdatedRegion);
foreach ($this->_cityListByRegionAdded as $countryCode => $cityListByRegionAdded) {
foreach ($cityListByRegionAdded as $regionCode => $cityListAdded) {
if (isset($this->_regionIdListByCountry[$countryCode][$regionCode])) {
$regionId = $this->_regionIdListByCountry[$countryCode][$regionCode];
$parentLocation = new CM_Model_Location(CM_Model_Location::LEVEL_STATE, $regionId);
} else {
$countryId = $this->_countryIdList[$countryCode];
$parentLocation = new CM_Model_Location(CM_Model_Location::LEVEL_COUNTRY, $countryId);
}
foreach ($cityListAdded as $cityCode => $cityName) {
$cityData = $this->_locationTree[$countryCode]['regions'][$regionCode]['cities'][$cityName]['location'];
$city = CM_Model_Location::createCity($parentLocation, $cityName, $cityData['latitude'], $cityData['longitude'], $cityData['maxMind']);
$cityId = $city->getId();
$this->_cityIdList[$cityCode] = $cityId;
$this->_printProgressCounter(++$item, $count);
}
}
}
unset($this->_regionIdListByCountry);
unset($this->_cityListByRegionAdded);
unset($this->_locationTree);
}
示例5: monitorSynchronizedCommands
public function monitorSynchronizedCommands()
{
$time = time();
$timeoutStamp = $time + self::TIMEOUT;
$process = $this->_getProcess();
$machineId = $this->_getMachineId();
$result = CM_Db_Db::select('cm_cli_command_manager_process', ['commandName', 'processId'], ['machineId' => $machineId]);
foreach ($result->fetchAll() as $row) {
$commandName = $row['commandName'];
$processId = (int) $row['processId'];
$where = ['machineId' => $machineId, 'commandName' => $commandName];
if ($process->isRunning($processId)) {
CM_Db_Db::update('cm_cli_command_manager_process', ['timeoutStamp' => $timeoutStamp], $where);
} else {
CM_Db_Db::delete('cm_cli_command_manager_process', $where);
}
}
CM_Db_Db::delete('cm_cli_command_manager_process', '`timeoutStamp` < ' . $time);
}
示例6: _updateLatestActivity
protected function _updateLatestActivity()
{
$currentTime = time();
CM_Db_Db::update('cm_user', array('activityStamp' => $currentTime), array('userId' => $this->getId()));
$this->_set('activityStamp', $currentTime);
}
示例7: setFile
/**
* @param CM_File_UserContent|null $file
*/
public function setFile(CM_File_UserContent $file = null)
{
$filename = null !== $file ? $file->getFileName() : null;
CM_Db_Db::update('cm_streamChannelArchive_media', ['file' => $filename], ['id' => $this->getId()]);
$this->_change();
}
示例8: setPercentage
/**
* @param int $percentage
*/
public function setPercentage($percentage)
{
$percentage = $this->_checkPercentage($percentage);
CM_Db_Db::update('cm_splitfeature', array('percentage' => $percentage), array('id' => $this->getId()));
$this->_change();
}
示例9: foreach
<?php
$rowList = CM_Db_Db::select('cm_log', '*')->fetchAll();
foreach ($rowList as $row) {
$metaInfo = @unserialize($row['metaInfo']);
if (is_array($metaInfo)) {
$variableInspector = new CM_Debug_VariableInspector();
$metaInfo = Functional\map($metaInfo, function ($value) use($variableInspector) {
return $variableInspector->getDebugInfo($value, ['recursive' => true]);
});
} else {
$metaInfo = null;
}
CM_Db_Db::update('cm_log', ['metaInfo' => serialize($metaInfo)], ['id' => $row['id']]);
}
示例10: unsetUser
public function unsetUser()
{
CM_Db_Db::update('cm_stream_publish', array('userId' => null), array('id' => $this->getId()));
$this->_change();
}
示例11: int
<?php
if (!CM_Db_Db::existsTable('cm_requestClientCounter')) {
CM_Db_Db::exec('
CREATE TABLE `cm_requestClientCounter` (
`counter` int(10) unsigned NOT NULL,
PRIMARY KEY (`counter`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
');
CM_Db_Db::insert('cm_requestClientCounter', array('counter' => 0));
}
if (CM_Db_Db::existsTable('cm_requestClient')) {
$highestEntry = (int) CM_Db_Db::select('cm_requestClient', 'id', null, array('id' => 'DESC'))->fetchColumn();
CM_Db_Db::update('cm_requestClientCounter', array('counter' => $highestEntry));
CM_Db_Db::exec('DROP TABLE IF EXISTS `cm_requestClient`;');
}
示例12: setOptimized
/**
* @param bool $optimized
* @return CM_Model_Splittest
*/
public function setOptimized($optimized)
{
$optimized = (bool) $optimized;
CM_Db_Db::update('cm_splittest', ['optimized' => $optimized], ['id' => $this->getId()]);
return $this->_change();
}
示例13: array
<?php
if (!CM_Db_Db::existsColumn('cm_languageKey', 'variables')) {
CM_Db_Db::exec("ALTER TABLE `cm_languageKey` ADD `variables` text CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL AFTER name");
}
if (CM_Db_Db::existsTable('cm_languageKey_variable')) {
$results = CM_Db_Db::select('cm_languageKey_variable', '*')->fetchAll();
$variableList = array();
foreach ($results as $result) {
$variableList[$result['languageKeyId']][] = $result['name'];
}
foreach ($variableList as $languageKeyId => $variables) {
CM_Db_Db::update('cm_languageKey', array('variables' => json_encode($variables)), array('id' => $languageKeyId));
}
CM_Db_Db::exec('DROP TABLE `cm_languageKey_variable`');
}
示例14: setPeriod
/**
* @param int|null $role
* @param int $period
*/
public function setPeriod($role, $period)
{
$role = $role ? (int) $role : null;
$period = (int) $period;
if (CM_Db_Db::count('cm_actionLimit', array('actionType' => $this->getActionType(), 'actionVerb' => $this->getActionVerb(), 'type' => $this->getType(), 'role' => $role))) {
CM_Db_Db::update('cm_actionLimit', array('period' => $period), array('actionType' => $this->getActionType(), 'actionVerb' => $this->getActionVerb(), 'type' => $this->getType(), 'role' => $role));
} else {
CM_Db_Db::insert('cm_actionLimit', array('period' => $period, 'actionType' => $this->getActionType(), 'actionVerb' => $this->getActionVerb(), 'type' => $this->getType(), 'role' => $role));
}
$this->_change();
}
示例15: _onDeleteBefore
protected function _onDeleteBefore()
{
CM_Db_Db::delete('cm_languageValue', array('languageId' => $this->getId()));
/** @var CM_Model_Language $language */
foreach (new CM_Paging_Language_All() as $language) {
if ($this->isBackingUp($language) && !$this->equals($language)) {
$language->setBackup(null);
}
}
CM_Db_Db::update('cm_user', array('languageId' => null), array('languageId' => $this->getId()));
}