예제 #1
0
파일: Model.php 프로젝트: cargomedia/cm
 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);
 }
예제 #2
0
 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();
 }
예제 #3
0
파일: All.php 프로젝트: cargomedia/cm
 /**
  * @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();
 }
예제 #4
0
 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);
 }
예제 #5
0
 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();
 }
예제 #6
0
 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());
 }
예제 #7
0
 protected function _onDeleteBefore()
 {
     CM_Db_Db::delete('cm_languageValue', array('languageKeyId' => $this->getId()));
 }
예제 #8
0
파일: MaxMind.php 프로젝트: cargomedia/cm
 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);
 }
예제 #9
0
파일: Language.php 프로젝트: cargomedia/cm
 protected function _onDelete()
 {
     CM_Db_Db::delete('cm_model_language', array('id' => $this->getId()));
 }
예제 #10
0
파일: Session.php 프로젝트: cargomedia/cm
 public static function deleteExpired()
 {
     CM_Db_Db::delete('cm_session', '`expires` < ' . time());
 }
예제 #11
0
 public function reset()
 {
     CM_Db_Db::delete('cm_user_preference', array('userId' => $this->_model->getId()));
     $this->_change();
 }
예제 #12
0
파일: Temp.php 프로젝트: NicolasSchmutz/cm
 public function delete($recursive = null)
 {
     CM_Db_Db::delete('cm_tmp_userfile', array('uniqid' => $this->getUniqid()));
     parent::delete();
 }
예제 #13
0
파일: Publish.php 프로젝트: cargomedia/cm
 protected function _onDelete()
 {
     CM_Db_Db::delete('cm_stream_publish', array('id' => $this->getId()));
 }
예제 #14
0
 private function _delete()
 {
     CM_Db_Db::delete('cm_captcha', array('captcha_id' => $this->getId()));
 }
예제 #15
0
파일: Abstract.php 프로젝트: cargomedia/cm
 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');
     }
 }
예제 #16
0
 protected function _onDelete()
 {
     CM_Db_Db::delete('entityMock', array('id' => $this->getId()));
 }
예제 #17
0
 /**
  * @param int $age Seconds
  */
 public static function deleteOlder($age)
 {
     $age = (int) $age;
     CM_Db_Db::delete('cm_action', '`createStamp` < ' . (time() - $age));
 }
예제 #18
0
 /**
  * @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();
 }
예제 #19
0
파일: Blocked.php 프로젝트: cargomedia/cm
 public static function deleteOld()
 {
     CM_Db_Db::delete('cm_ipBlocked', '`expirationStamp` < ' . time());
 }
예제 #20
0
파일: Mail.php 프로젝트: NicolasSchmutz/cm
 /**
  * @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']));
     }
 }
예제 #21
0
 protected function _onDelete()
 {
     CM_Db_Db::delete('modelThasIsAnAssetMock', array('id' => $this->getId()));
 }
예제 #22
0
파일: Media.php 프로젝트: cargomedia/cm
 protected function _onDelete()
 {
     CM_Db_Db::delete('cm_streamChannel_media', array('id' => $this->getId()));
     parent::_onDelete();
 }
예제 #23
0
 /**
  * @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));
 }
예제 #24
0
파일: Roles.php 프로젝트: cargomedia/cm
 /**
  * @param int $role
  */
 public function delete($role)
 {
     CM_Db_Db::delete('cm_role', array('userId' => $this->_model->getId(), 'role' => $role));
     $this->_change();
 }
예제 #25
0
 public function flush()
 {
     CM_Db_Db::delete('cm_log', array('type' => $this->getType()));
 }
예제 #26
0
파일: User.php 프로젝트: aladin1394/CM
 protected function _onDelete()
 {
     CM_Db_Db::delete('cm_user', array('userId' => $this->getId()));
 }
예제 #27
0
 protected function _onDelete()
 {
     CM_Db_Db::delete('cm_splitfeature', array('id' => $this->getId()));
 }
예제 #28
0
 /**
  * @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]);
 }
예제 #29
0
파일: Video.php 프로젝트: NicolasSchmutz/cm
 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);
 }
예제 #30
0
파일: 71.php 프로젝트: cargomedia/cm
<?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');
}