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


PHP CM_Db_Db类代码示例

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


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

示例1: 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

示例2: _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

示例3: _load

 protected function _load()
 {
     $result = CM_Db_Db::select('cm_model_languagekey', 'name', 'name LIKE ".%"', 'name ASC');
     while ($section = $result->fetch()) {
         $this->_addLanguageNode($section['name']);
     }
 }
开发者ID:NicolasSchmutz,项目名称:cm,代码行数:7,代码来源:Language.php

示例4: _dbToFileSql

 /**
  * @param string $namespace
  */
 private function _dbToFileSql($namespace)
 {
     $namespace = (string) $namespace;
     $tables = CM_Db_Db::exec("SHOW TABLES LIKE ?", array(strtolower($namespace) . '_%'))->fetchAllColumn();
     sort($tables);
     $dump = CM_Db_Db::getDump($tables, true);
     CM_File::create(CM_Util::getModulePath($namespace) . '/resources/db/structure.sql', $dump);
 }
开发者ID:cargomedia,项目名称:cm,代码行数:11,代码来源:Cli.php

示例5: findByData

 public function findByData($type, array $data)
 {
     $result = CM_Db_Db::select($this->_getTableName($type), array('id'), $data)->fetch();
     if (false === $result) {
         $result = null;
     }
     return $result;
 }
开发者ID:aladin1394,项目名称:CM,代码行数:8,代码来源:Database.php

示例6: test_Get

 public function test_Get()
 {
     $user = CMTest_TH::createUser();
     $user->getRoles()->add(self::ROLE_A, 2000);
     $stamps = CM_Db_Db::select('cm_role', array('startStamp', 'expirationStamp'), array('userId' => $user->getId()))->fetch();
     $this->assertEquals($stamps['startStamp'], $user->getRoles()->getStartStamp(self::ROLE_A));
     $this->assertEquals($stamps['expirationStamp'], $user->getRoles()->getExpirationStamp(self::ROLE_A));
 }
开发者ID:cargomedia,项目名称:cm,代码行数:8,代码来源:RolesTest.php

示例7: 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

示例8: deleteOlder

 /**
  * @param int $age
  */
 public static function deleteOlder($age)
 {
     $age = (int) $age;
     $result = CM_Db_Db::select('cm_tmp_userfile', 'uniqid', '`createStamp` < ' . (time() - $age));
     foreach ($result->fetchAllColumn() as $uniqid) {
         $tmpFile = new CM_File_UserContent_Temp($uniqid);
         $tmpFile->delete();
     }
 }
开发者ID:NicolasSchmutz,项目名称:cm,代码行数:12,代码来源:Temp.php

示例9: reload

 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();
 }
开发者ID:cargomedia,项目名称:cm,代码行数:10,代码来源:SetupScript.php

示例10: remove

 /**
  * @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();
 }
开发者ID:cargomedia,项目名称:cm,代码行数:13,代码来源:All.php

示例11: testDelete

 public function testDelete()
 {
     $language = CM_Model_Language::create('Foo', 'foo', true);
     $language->setTranslation('foo', 'bar');
     $this->assertSame(array('foo' => array('value' => 'bar', 'variables' => array())), $language->getTranslations()->getAssociativeArray());
     $languageKey = CM_Model_LanguageKey::findByName('foo');
     $languageKey->delete();
     $this->assertSame(array(), $language->getTranslations()->getAssociativeArray());
     $this->assertSame(0, CM_Db_Db::count('cm_model_languagekey', array('name' => 'foo')));
     $this->assertSame(0, CM_Db_Db::count('cm_languageValue', array('languageKeyId' => $languageKey->getId(), 'languageId' => $language->getId())));
 }
开发者ID:NicolasSchmutz,项目名称:cm,代码行数:11,代码来源:LanguageKeyTest.php

示例12: queueOutstanding

 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);
 }
开发者ID:cargomedia,项目名称:cm,代码行数:12,代码来源:DelayedQueue.php

示例13: 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

示例14: 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

示例15: testCacheCustom

 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());
 }
开发者ID:cargomedia,项目名称:cm,代码行数:15,代码来源:AbstractTest.php


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