当前位置: 首页>>代码示例>>PHP>>正文


PHP CM_Db_Db::insert方法代码示例

本文整理汇总了PHP中CM_Db_Db::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP CM_Db_Db::insert方法的具体用法?PHP CM_Db_Db::insert怎么用?PHP CM_Db_Db::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CM_Db_Db的用法示例。


在下文中一共展示了CM_Db_Db::insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _createStatic

 protected static function _createStatic(array $data)
 {
     $user = null;
     $userId = null;
     if (isset($data['user'])) {
         /** @var CM_Model_User $user */
         $user = $data['user'];
         $userId = $user->getId();
     }
     $key = (string) $data['key'];
     $start = (int) $data['start'];
     /** @var CM_Model_StreamChannel_Abstract $streamChannel */
     $streamChannel = $data['streamChannel'];
     if (!$streamChannel->isValid()) {
         throw new CM_Exception_Invalid('Stream channel not valid', null, array('severity' => CM_Exception::WARN));
     }
     $allowedUntil = $streamChannel->canSubscribe($user, time());
     if ($allowedUntil <= time()) {
         throw new CM_Exception_NotAllowed('Not allowed to subscribe');
     }
     $id = CM_Db_Db::insert('cm_stream_subscribe', array('userId' => $userId, 'start' => $start, 'allowedUntil' => $allowedUntil, 'channelId' => $streamChannel->getId(), 'key' => $key));
     $streamSubscribe = new self($id);
     $streamChannel->onSubscribe($streamSubscribe);
     return $streamSubscribe;
 }
开发者ID:aladin1394,项目名称:CM,代码行数:25,代码来源:Subscribe.php

示例2: createEntry

 /**
  * @param string $name
  * @return int
  */
 public function createEntry($name)
 {
     $id = CM_Db_Db::insert('index_mock', array('name' => (string) $name));
     $this->updateDocuments($id);
     $this->refreshIndex();
     return (int) $id;
 }
开发者ID:cargomedia,项目名称:cm,代码行数:11,代码来源:AbstractTest.php

示例3: addTraining

 /**
  * @param int   $class
  * @param array $values Feature=>Value pairs
  */
 public function addTraining($class, array $values)
 {
     $class = (int) $class;
     $values = $this->_parseValues($values);
     $time = time();
     CM_Db_Db::insert('cm_svmtraining', array('svmId' => $this->getId(), 'class' => $class, 'values' => serialize($values), 'createStamp' => $time));
     CM_Db_Db::replace('cm_svm', array('id' => $this->getId(), 'updateStamp' => $time));
 }
开发者ID:cargomedia,项目名称:cm,代码行数:12,代码来源:Model.php

示例4: testTrailingWhitespaceInLanguageKeyName

 public function testTrailingWhitespaceInLanguageKeyName()
 {
     CM_Db_Db::insert('cm_model_languagekey', ['name'], [['foo '], ['foo']]);
     $language = CM_Model_Language::create('Foo', 'foo', true);
     $language->getTranslations()->getAssociativeArray();
     $this->assertEquals(['foo ', 'foo'], array_keys($language->getTranslations()->getAssociativeArray()));
     $this->assertCount(2, $language->getTranslations());
 }
开发者ID:cargomedia,项目名称:cm,代码行数:8,代码来源:AbstractTest.php

示例5: create

 public function create($type, array $data)
 {
     $id = CM_Db_Db::insert($this->_getTableName($type), $data);
     if (null === $id) {
         throw new CM_Exception_Invalid('Insert statement did not return an ID');
     }
     return array('id' => (int) $id);
 }
开发者ID:aladin1394,项目名称:CM,代码行数:8,代码来源:Database.php

示例6: set

 /**
  * @param string      $phrase
  * @param string|null $value
  * @param array|null  $variables
  */
 public function set($phrase, $value = null, array $variables = null)
 {
     if (null === $value) {
         $value = $phrase;
     }
     $languageKey = CM_Model_LanguageKey::replace($phrase, $variables);
     CM_Db_Db::insert('cm_languageValue', array('value' => $value, 'languageKeyId' => $languageKey->getId(), 'languageId' => $this->_language->getId()), null, array('value' => $value));
     $this->_change();
 }
开发者ID:NicolasSchmutz,项目名称:cm,代码行数:14,代码来源:Language.php

示例7: setUp

    public function setUp()
    {
        CM_Db_Db::exec('CREATE TABLE `test` (
						`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
						`num` INT(10) NOT NULL,
						PRIMARY KEY (`id`)
						)');
        for ($i = 0; $i < 100; $i++) {
            CM_Db_Db::insert('test', array('num' => $i));
        }
    }
开发者ID:cargomedia,项目名称:cm,代码行数:11,代码来源:AbstractTest.php

示例8: testGetInvalidMetaInfo

 public function testGetInvalidMetaInfo()
 {
     $paging = $this->getMockBuilder('CM_Paging_Log_Abstract')->setMethods(array('getType'))->disableOriginalConstructor()->getMockForAbstractClass();
     $paging->expects($this->any())->method('getType')->will($this->returnValue(14));
     /** @var CM_Paging_Log_Abstract $paging */
     $paging->__construct();
     CM_Db_Db::insert('cm_log', array('msg' => 'foo', 'metaInfo' => str_ireplace('{', '/', serialize(array('foo' => 'bar'))), 'timeStamp' => time(), 'type' => 14));
     $items = $paging->getItems();
     $this->assertSame(1, count($items));
     $this->assertSame('foo', $items[0]['msg']);
     $this->assertSame(null, $items[0]['metaInfo']);
 }
开发者ID:NicolasSchmutz,项目名称:cm,代码行数:12,代码来源:AbstractTest.php

示例9: testPrepare

 public function testPrepare()
 {
     $actor = CMTest_TH::createUser();
     $action = new CM_Action_Mock('foo', $actor);
     $action->prepare(null);
     CM_Db_Db::insert('cm_actionLimit', array('type' => 1, 'actionType' => 1, 'actionVerb' => 1, 'role' => null, 'limit' => 0, 'period' => 0));
     CMTest_TH::clearCache();
     try {
         $action->prepare(null);
         $this->fail('Limited action did not throw exception');
     } catch (CM_Exception_ActionLimit $e) {
         $this->assertSame('Mock overshoot', $e->getMessage());
     }
 }
开发者ID:cargomedia,项目名称:cm,代码行数:14,代码来源:MockTest.php

示例10: create

 /**
  * @param string                  $filename
  * @param string|null             $content
  * @param CM_File_Filesystem|null $filesystem
  * @throws CM_Exception_Invalid
  * @return CM_File_UserContent_Temp
  */
 public static function create($filename, $content = null, CM_File_Filesystem $filesystem = null)
 {
     if ($filesystem) {
         throw new CM_Exception_Invalid('Temporary user-content file cannot handle filesystem');
     }
     $filename = (string) $filename;
     if (strlen($filename) > 100) {
         $filename = substr($filename, -100, 100);
     }
     $uniqid = md5(rand() . uniqid());
     CM_Db_Db::insert('cm_tmp_userfile', array('uniqid' => $uniqid, 'filename' => $filename, 'createStamp' => time()));
     $file = new self($uniqid);
     $file->ensureParentDirectory();
     if (null !== $content) {
         $file->write($content);
     }
     return $file;
 }
开发者ID:NicolasSchmutz,项目名称:cm,代码行数:25,代码来源:Temp.php

示例11: setUpBeforeClass

    public static function setUpBeforeClass()
    {
        CM_Db_Db::exec('CREATE TABLE `test_a` (
						`id` INT(10) unsigned NOT NULL AUTO_INCREMENT,
						`num` INT(10) NOT NULL,
						PRIMARY KEY (`id`)
						)');
        for ($i = 1; $i <= 10; $i++) {
            CM_Db_Db::insert('test_a', array('num' => $i % 5));
        }
        CM_Db_Db::exec('CREATE TABLE `test_b` (
						`id` INT(10) unsigned NOT NULL AUTO_INCREMENT,
						`num` INT(10) NOT NULL,
						PRIMARY KEY (`id`)
						)');
        for ($i = 1; $i <= 5; $i++) {
            CM_Db_Db::insert('test_b', array('num' => $i % 5));
        }
    }
开发者ID:cargomedia,项目名称:cm,代码行数:19,代码来源:PagingsTest.php

示例12: _createStatic

 protected static function _createStatic(array $data)
 {
     /** @var CM_Model_User $user */
     $user = $data['user'];
     /** @var CM_Model_StreamChannel_Abstract $streamChannel */
     $streamChannel = $data['streamChannel'];
     $start = (int) $data['start'];
     if (!$streamChannel->isValid()) {
         throw new CM_Exception_Invalid('Stream channel not valid', CM_Exception::WARN);
     }
     $allowedUntil = $streamChannel->canPublish($user, time());
     if ($allowedUntil <= time()) {
         throw new CM_Exception_NotAllowed('Not allowed to publish');
     }
     $key = (string) $data['key'];
     $id = CM_Db_Db::insert('cm_stream_publish', array('userId' => $user->getId(), 'start' => $start, 'allowedUntil' => $allowedUntil, 'key' => $key, 'channelId' => $streamChannel->getId()));
     $streamPublish = new self($id);
     $streamChannel->onPublish($streamPublish);
     return $streamPublish;
 }
开发者ID:NicolasSchmutz,项目名称:cm,代码行数:20,代码来源:Publish.php

示例13: _lockCommand

 /**
  * @param CM_Cli_Command $command
  */
 protected function _lockCommand(CM_Cli_Command $command)
 {
     $commandName = $command->getName();
     $process = $this->_getProcess();
     $hostId = $process->getHostId();
     $processId = $process->getProcessId();
     $timeoutStamp = time() + self::TIMEOUT;
     CM_Db_Db::insert('cm_cli_command_manager_process', array('commandName' => $commandName, 'hostId' => $hostId, 'processId' => $processId, 'timeoutStamp' => $timeoutStamp));
 }
开发者ID:NicolasSchmutz,项目名称:cm,代码行数:12,代码来源:CommandManager.php

示例14: array

// 1) Duplicate entry for the city "Saint John's"
// Setting the region code to "Newfoundland and Labrador" for one of them
// to achieve consistency with the updated GeoIP data
CM_Db_Db::update('cm_model_location_city', array('stateId' => 2524), array('id' => 22256));
// 2) Duplicate entries for the cities "Apo"/"Fpo" (U.S. Army post offices)
// Adding region entries for the U.S. Armed Forces Americas & Pacific
$idUS = CM_Db_Db::select('cm_model_location_country', 'id', array('abbreviation' => 'US'))->fetchColumn();
if (false === $idUS) {
    throw new CM_Exception_Invalid('No country with abbreviation `US` found');
}
$idUS = (int) $idUS;
$armedForcesRegionList = array('AA' => 'Armed Forces Americas', 'AE' => 'Armed Forces Europe, Middle East, & Canada', 'AP' => 'Armed Forces Pacific');
$idArmedForcesList = array();
foreach ($armedForcesRegionList as $regionCode => $regionName) {
    $idArmedForces = CM_Db_Db::select('cm_model_location_state', 'id', array('countryId' => $idUS, 'abbreviation' => $regionCode))->fetchColumn();
    if (false === $idArmedForces) {
        $idArmedForces = CM_Db_Db::insert('cm_model_location_state', array('countryId' => $idUS, 'abbreviation' => $regionCode, 'name' => $regionName));
    } else {
        CM_Db_Db::update('cm_model_location_state', array('name' => $regionName), array('countryId' => $idUS, 'abbreviation' => $regionCode));
    }
    $idArmedForcesList[$regionCode] = (int) $idArmedForces;
}
// Moving the duplicate cities to the correct regions
$armedForcesCityList = array('AA' => array(173158, 173159), 'AE' => array(173160, 173161), 'AP' => array(173944, 173945));
foreach ($armedForcesCityList as $regionCode => $cityIdList) {
    $regionId = $idArmedForcesList[$regionCode];
    foreach ($cityIdList as $cityId) {
        CM_Db_Db::update('cm_model_location_city', array('stateId' => $regionId), array('id' => $cityId));
    }
}
开发者ID:cargomedia,项目名称:cm,代码行数:30,代码来源:28.php

示例15: _createStatic

 protected static function _createStatic(array $data)
 {
     return new self(CM_Db_Db::insert('modelThasIsAnAssetMock', array('modelMockId' => $data['modelMockId'], 'bar' => $data['bar'])));
 }
开发者ID:aladin1394,项目名称:CM,代码行数:4,代码来源:AbstractTest.php


注:本文中的CM_Db_Db::insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。