public function flush() { CM_Db_Db::delete('cm_svmtraining', array('svmId' => $this->getId())); CM_Db_Db::replace('cm_svm', array('id' => $this->getId(), 'updateStamp' => time())); $file = $this->_getFile(); $file->delete(); $this->__construct($this->_id); }
public function reload(CM_OutputStream_Interface $output) { $tableNames = CM_Db_Db::exec('SHOW TABLES')->fetchAllColumn(); CM_Db_Db::exec('SET foreign_key_checks = 0;'); foreach ($tableNames as $table) { CM_Db_Db::delete($table); } CM_Db_Db::exec('SET foreign_key_checks = 1;'); $this->_setInitialVersion(); }
/** * @param string $phrase */ public function remove($phrase) { $languageKey = CM_Model_LanguageKey::findByName($phrase); if (!$languageKey) { return; } CM_Db_Db::delete('cm_languageValue', array('languageKeyId' => $languageKey->getId(), 'languageId' => $this->_language->getId())); $this->_change(); (new self($this->_language, !$this->_javascriptOnly))->_change(); }
public function queueOutstanding() { $executeAtMax = time(); $result = CM_Db_Db::select('cm_jobdistribution_delayedqueue', '*', '`executeAt` <= ' . $executeAtMax, '`executeAt` ASC'); while ($row = $result->fetch()) { $job = $this->_instantiateJob($row['className']); if ($job) { $job->queue(CM_Params::decode($row['params'], true)); } } CM_Db_Db::delete('cm_jobdistribution_delayedqueue', '`executeAt` <= ' . $executeAtMax); }
public function testCache() { $source = new CM_PagingSource_Sql('`num`', 'test'); $source->enableCache(); $this->assertSame(100, $source->getCount()); $sourceNocache = new CM_PagingSource_Sql('`num`', 'test'); $this->assertSame(100, $sourceNocache->getCount()); CM_Db_Db::delete('test', array('num' => 0)); $this->assertSame(100, $source->getCount()); $this->assertSame(99, $sourceNocache->getCount()); $source->clearCache(); $this->assertSame(99, $source->getCount()); $this->assertSame(99, $sourceNocache->getCount()); CM_Cache_Shared::getInstance()->flush(); }
public function testCacheCustom() { $source = new CM_PagingSource_Sql('`num`', 'test'); $fileCache = CM_Cache_Persistent::getInstance(); $source->enableCache(null, $fileCache); $this->assertEquals(100, $source->getCount()); CM_Db_Db::delete('test', array('num' => 0)); $this->assertEquals(100, $source->getCount()); $source->clearCache(); $this->assertEquals(99, $source->getCount()); CM_Db_Db::delete('test', array('num' => 1)); $this->assertEquals(99, $source->getCount()); $fileCache->flush(); $this->assertEquals(98, $source->getCount()); }
protected function _onDeleteBefore() { CM_Db_Db::delete('cm_languageValue', array('languageKeyId' => $this->getId())); }
protected function _upgradeRegionList() { $this->_streamOutput->writeln('Updating regions database…'); $count = $this->_count(array($this->_regionListByCountryRenamed, $this->_regionListByCountryUpdatedCode, $this->_regionListByCountryAdded, $this->_regionListByCountryRemovedCodeInUse), 3); $item = 0; foreach ($this->_regionListByCountryRenamed as $countryCode => $regionListRenamed) { foreach ($regionListRenamed as $regionCode => $regionNames) { $regionName = $regionNames['name']; $maxMindRegion = $countryCode . $regionCode; if (!CM_Db_Db::update('cm_model_location_state', array('name' => $regionName), array('_maxmind' => $maxMindRegion))) { // For the USA, where the old numeric region codes in _maxmind have been removed from MaxMind's newer region databases $countryId = $this->_countryIdList[$countryCode]; CM_Db_Db::update('cm_model_location_state', array('name' => $regionName), array('countryId' => $countryId, 'abbreviation' => $regionCode)); } $this->_printProgressCounter(++$item, $count); } } unset($this->_regionListByCountryRenamed); foreach ($this->_regionListByCountryUpdatedCode as $countryCode => $regionListUpdatedCode) { foreach ($regionListUpdatedCode as $regionCode) { $regionId = $this->_regionIdListByCountry[$countryCode][$regionCode]; $maxMindRegion = $countryCode . $regionCode; $abbreviationRegion = 'US' === $countryCode ? $regionCode : null; CM_Db_Db::update('cm_model_location_state', array('_maxmind' => $maxMindRegion, 'abbreviation' => $abbreviationRegion), array('id' => $regionId)); $this->_printProgressCounter(++$item, $count); } } unset($this->_regionListByCountryUpdatedCode); foreach ($this->_regionListByCountryAdded as $countryCode => $regionListAdded) { $countryId = $this->_countryIdList[$countryCode]; $country = new CM_Model_Location(CM_Model_Location::LEVEL_COUNTRY, $countryId); foreach ($regionListAdded as $regionCode => $regionName) { $abbreviationRegion = 'US' === $countryCode ? $regionCode : null; $maxMindRegion = $countryCode . $regionCode; $region = CM_Model_Location::createState($country, $regionName, $abbreviationRegion, $maxMindRegion); $regionId = $region->getId(); $this->_regionIdListByCountry[$countryCode][$regionCode] = $regionId; if (isset($this->_locationTree[$countryCode]['regions'][$regionCode]['location']['maxMind'])) { $maxMind = $this->_locationTree[$countryCode]['regions'][$regionCode]['location']['maxMind']; $this->_regionIdListByMaxMind[$maxMind] = $regionId; } $this->_printProgressCounter(++$item, $count); } } unset($this->_regionListByCountryAdded); foreach ($this->_regionListByCountryRemovedCodeInUse as $countryCode => $regionListRemovedCodeInUse) { foreach ($regionListRemovedCodeInUse as $regionIdOld => $regionCode) { CM_Db_Db::delete('cm_model_location_state', array('id' => $regionIdOld)); $regionId = $this->_regionIdListByCountry[$countryCode][$regionCode]; CM_Db_Db::update('cm_model_location_city', array('stateId' => $regionId), array('stateId' => $regionIdOld)); $this->_printProgressCounter(++$item, $count); } } unset($this->_regionListByCountryRemovedCodeInUse); }
protected function _onDelete() { CM_Db_Db::delete('cm_model_language', array('id' => $this->getId())); }
public static function deleteExpired() { CM_Db_Db::delete('cm_session', '`expires` < ' . time()); }
public function reset() { CM_Db_Db::delete('cm_user_preference', array('userId' => $this->_model->getId())); $this->_change(); }
public function delete($recursive = null) { CM_Db_Db::delete('cm_tmp_userfile', array('uniqid' => $this->getUniqid())); parent::delete(); }
protected function _onDelete() { CM_Db_Db::delete('cm_stream_publish', array('id' => $this->getId())); }
private function _delete() { CM_Db_Db::delete('cm_captcha', array('captcha_id' => $this->getId())); }
protected function _onDelete() { try { CM_Db_Db::delete('cm_streamChannel', array('id' => $this->getId())); } catch (CM_Db_Exception $e) { throw new CM_Exception_Invalid('Cannot delete streamChannel with existing streams'); } }
protected function _onDelete() { CM_Db_Db::delete('entityMock', array('id' => $this->getId())); }
/** * @param int $age Seconds */ public static function deleteOlder($age) { $age = (int) $age; CM_Db_Db::delete('cm_action', '`createStamp` < ' . (time() - $age)); }
/** * @param int|null $role */ public function unsetLimit($role = null) { $role = $role ? (int) $role : null; CM_Db_Db::delete('cm_actionLimit', array('actionType' => $this->getActionType(), 'actionVerb' => $this->getActionVerb(), 'type' => $this->getType(), 'role' => $role)); $this->_change(); }
public static function deleteOld() { CM_Db_Db::delete('cm_ipBlocked', '`expirationStamp` < ' . time()); }
/** * @param int $limit */ public static function processQueue($limit) { $limit = (int) $limit; $result = CM_Db_Db::execRead('SELECT * FROM `cm_mail` ORDER BY `createStamp` LIMIT ' . $limit); while ($row = $result->fetch()) { $mail = new CM_Mail(); foreach (unserialize($row['to']) as $to) { $mail->addTo($to['address'], $to['name']); } foreach (unserialize($row['replyTo']) as $replyTo) { $mail->addReplyTo($replyTo['address'], $replyTo['name']); } foreach (unserialize($row['cc']) as $cc) { $mail->addCc($cc['address'], $cc['name']); } foreach (unserialize($row['bcc']) as $bcc) { $mail->addBcc($bcc['address'], $bcc['name']); } if ($headerList = unserialize($row['customHeaders'])) { foreach ($headerList as $label => $valueList) { foreach ($valueList as $value) { $mail->addCustomHeader($label, $value); } } } $sender = unserialize($row['sender']); $mail->setSender($sender['address'], $sender['name']); $mail->_send($row['subject'], $row['text'], $row['html']); CM_Db_Db::delete('cm_mail', array('id' => $row['id'])); } }
protected function _onDelete() { CM_Db_Db::delete('modelThasIsAnAssetMock', array('id' => $this->getId())); }
protected function _onDelete() { CM_Db_Db::delete('cm_streamChannel_media', array('id' => $this->getId())); parent::_onDelete(); }
/** * @param CM_Cli_Command $command */ public function unlockCommand(CM_Cli_Command $command) { $commandName = $command->getName(); $process = $this->_getProcess(); $hostId = $process->getHostId(); $processId = $process->getProcessId(); CM_Db_Db::delete('cm_cli_command_manager_process', array('commandName' => $commandName, 'hostId' => $hostId, 'processId' => $processId)); }
/** * @param int $role */ public function delete($role) { CM_Db_Db::delete('cm_role', array('userId' => $this->_model->getId(), 'role' => $role)); $this->_change(); }
public function flush() { CM_Db_Db::delete('cm_log', array('type' => $this->getType())); }
protected function _onDelete() { CM_Db_Db::delete('cm_user', array('userId' => $this->getId())); }
protected function _onDelete() { CM_Db_Db::delete('cm_splitfeature', array('id' => $this->getId())); }
/** * @param CM_Cli_Command $command */ public function unlockCommand(CM_Cli_Command $command) { $commandName = $command->getName(); $machineId = $this->_getMachineId(); $processId = $this->_getProcess()->getProcessId(); CM_Db_Db::delete('cm_cli_command_manager_process', ['commandName' => $commandName, 'machineId' => $machineId, 'processId' => $processId]); }
protected static function _createStatic(array $data) { $key = (string) $data['key']; $width = (int) $data['width']; $height = (int) $data['height']; $serverId = $data['serverId']; $thumbnailCount = (int) $data['thumbnailCount']; $adapterType = (int) $data['adapterType']; $id = CM_Db_Db::insert('cm_streamChannel', array('key' => $key, 'type' => static::getTypeStatic(), 'adapterType' => $adapterType)); try { CM_Db_Db::insert('cm_streamChannel_video', array('id' => $id, 'width' => $width, 'height' => $height, 'serverId' => $serverId, 'thumbnailCount' => $thumbnailCount)); } catch (CM_Exception $ex) { CM_Db_Db::delete('cm_streamChannel', array('id' => $id)); throw $ex; } return new static($id); }
<?php if (CM_Db_Db::existsColumn('cm_cli_command_manager_process', 'hostId')) { CM_Db_Db::exec(' ALTER TABLE `cm_cli_command_manager_process` DROP KEY `hostId`, DROP COLUMN `hostId`, ADD COLUMN `machineId` varchar(100) NOT NULL AFTER `commandName`, ADD KEY `machineId` (`machineId`) '); CM_Db_Db::delete('cm_cli_command_manager_process'); }