• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP dmDb类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: executeNewMultipleFile

 /**
  * Allows the upload of multiple files 
  * 
  * @param sfWebRequest $request
  */
 public function executeNewMultipleFile(dmWebRequest $request)
 {
     // Retrived the folder by folder_id or by object in case of usage in dmMedia/gallery module
     if ($request->hasParameter('folder_id')) {
         $folderId = $request->getParameter('folder_id');
     } else {
         $objectModel = $request->getParameter('model');
         $objectPk = $request->getParameter('pk');
         $object = dmDb::table($objectModel)->find($objectPk);
         $folderId = $object->getDmMediaFolder()->getId();
     }
     $this->forward404Unless($folder = dmDb::table('DmMediaFolder')->find($folderId));
     if (!$folder->isWritable()) {
         $this->getUser()->logAlert($this->getI18n()->__('Folder %1% is not writable', array('%1%' => $folder->fullPath)));
     }
     $form = new dmMediaUploadifyForm();
     $form->setDefault('dm_media_folder_id', $folder->id);
     if ($request->isMethod('post') && $form->bindAndValid($request)) {
         $media = $form->save();
         if (isset($object)) {
             $object->addMedia($media);
             // In dmMedia/gallery usage, we also need to associate with the object
         }
         return $this->renderText('success');
     }
     $action = '+/dmMediaUploadifyerAdmin/newMultipleFile?' . (isset($object) ? "&model={$objectModel}&pk={$objectPk}" : 'folder_id=' . $folder->id);
     return $this->renderAsync(array('html' => $form->render('.dm_form.list.little action="' . $action . '"'), 'css' => $form->getStylesheets(), 'js' => $form->getJavascripts()));
 }
开发者ID:VanTanev,项目名称:dmMediaUploadifyerPlugin,代码行数:33,代码来源:actions.class.php


示例2: getPages

 protected function getPages($includeCurrent = true)
 {
     $treeObject = dmDb::table('DmPage')->getTree();
     $baseQuery = dmDb::table('DmPage')->createQuery('p')->withI18n();
     if (!isset($this->compiledVars['includeInactivePages']) || !$this->compiledVars['includeInactivePages']) {
         $baseQuery->where('pTranslation.is_active = ?', true);
     }
     $treeObject->setBaseQuery($baseQuery);
     if (!($currentPage = $this->context->getPage())) {
         throw new dmException('No current page');
     }
     $ancestors = $currentPage->getNode()->getAncestors();
     $ancestors = $ancestors ? $ancestors : array();
     $treeObject->resetBaseQuery();
     if ($includeCurrent) {
         $ancestors[] = $currentPage;
     }
     $pages = array();
     foreach ($ancestors as $page) {
         $pages[$page->get('module') . '/' . $page->get('action') . '/' . $page->getRecordId()] = $page;
     }
     /*
      * Allow listeners of dm.bread_crumb.filter_pages event
      * to filter and modify the pages list
      */
     return $this->context->getEventDispatcher()->filter(new sfEvent($this, 'dm.bread_crumb.filter_pages', array('page' => $this->context->getPage())), $pages)->getReturnValue();
 }
开发者ID:theolymp,项目名称:diem,代码行数:27,代码来源:dmWidgetNavigationBreadCrumbView.php


示例3: executeRate

 public function executeRate(sfWebRequest $request)
 {
     $this->forward404Unless($request->isMethod('POST'));
     list($class, $id) = dmString::decode($request->getParameter('hash'));
     $this->forward404Unless($table = dmDb::table($class));
     $this->forward404Unless($record = $table->find($id));
     $this->forward404Unless($table->hasTemplate('DmRatable'));
     $template = $table->getTemplate('DmRatable');
     $options = $template->getOptions();
     $value = (int) $request->getParameter('value');
     $this->forward404Unless($value >= 0 && $value <= $options['max_rate']);
     $rate = array('rate' => $value);
     if ($options['user']) {
         $this->forward404Unless($this->getUser()->isAuthenticated());
         $rate['dm_user_id'] = $this->getUser()->getUserId();
     } else {
         $rate['session_id'] = session_id();
     }
     if ($value) {
         $record->addRate($rate);
         $message = $this->getService('i18n')->__('Rating saved (%rate%)', array('%rate%' => $value));
     } else {
         $record->cancelRate($rate);
         $message = $this->getService('i18n')->__('Rating removed');
     }
     return $this->renderComponent('dmRatable', 'rating', array('record' => $record, 'message' => $message));
 }
开发者ID:KnpLabs,项目名称:dmRatablePlugin,代码行数:27,代码来源:actions.class.php


示例4: updateDatabase

 /**
  * Update changed documentation pages in database
  */
 protected function updateDatabase($branch)
 {
     $types = dmDb::query('Doc d')->select('d.type')->distinct()->fetchFlat();
     $cultures = sfConfig::get('dm_i18n_cultures');
     $originalCulture = sfDoctrineRecord::getDefaultCulture();
     foreach ($types as $type) {
         foreach ($cultures as $culture) {
             sfDoctrineRecord::setDefaultCulture($culture);
             $dir = dmOs::join($this->repo->getDir(), $type, $culture);
             $files = sfFinder::type('file')->name('/^\\d{2}\\s-\\s.+\\.markdown$/')->in($dir);
             foreach ($files as $file) {
                 $docName = preg_replace('/^\\d{2}\\s-\\s(.+)\\.markdown$/', '$1', basename($file));
                 $docRecord = dmDb::query('DocPage dp')->withI18n()->innerJoin('dp.Doc doc')->innerJoin('doc.Branch branch')->where('branch.number = ?', $branch)->andWhere('doc.type = ?', $type)->andWhere('dpTranslation.name = ?', $docName)->fetchOne();
                 if ($docRecord) {
                     $docText = file_get_contents($file);
                     if ($docRecord->text != $docText) {
                         $docRecord->text = $docText;
                         $docRecord->save();
                     }
                 }
             }
         }
     }
     sfDoctrineRecord::setDefaultCulture($originalCulture);
 }
开发者ID:Regmaya,项目名称:diem-project,代码行数:28,代码来源:gitDocumentationSynchronizer.php


示例5: getDmMediaFolder

 /**
  * @return DmMediaFolder the DmMediaFolder used to store this table's record's medias
  */
 public function getDmMediaFolder()
 {
     if ($this->hasCache('dm_media_folder')) {
         return $this->getCache('dm_media_folder');
     }
     return $this->setCache('dm_media_folder', dmDb::table('DmMediaFolder')->findOneByRelPathOrCreate($this->getDmModule()->getUnderscore()));
 }
开发者ID:Regmaya,项目名称:diem,代码行数:10,代码来源:dmDoctrineTable.php


示例6: executeImportSentences

 public function executeImportSentences(dmWebRequest $request)
 {
     $catalogue = $this->getObjectOrForward404($request);
     $form = new DmCatalogueImportForm();
     sfContext::getInstance()->getConfiguration()->loadHelpers(array('Url'));
     if ($request->isMethod('post') && $form->bindAndValid($request)) {
         $file = $form->getValue('file');
         $override = $form->getValue('override');
         $dataFile = $file->getTempName();
         $table = dmDb::table('DmTransUnit');
         $existQuery = $table->createQuery('t')->select('t.id, t.source, t.target, t.created_at, t.updated_at')->where('t.dm_catalogue_id = ? AND t.source = ?');
         $catalogueId = $catalogue->get('id');
         $nbAdded = 0;
         $nbUpdated = 0;
         try {
             if (!is_array($data = sfYaml::load(file_get_contents($dataFile)))) {
                 $this->getUser()->logError($this->getI18n()->__('Could not load file: %file%', array('%file%' => $file->getOriginalName())));
                 return $this->renderPartial('dmInterface/flash');
             }
         } catch (Exception $e) {
             $this->getUser()->logError($this->getI18n()->__('Unable to parse file: %file%', array('%file%' => $file->getOriginalName())));
             return $this->renderPartial('dmInterface/flash');
         }
         $addedTranslations = new Doctrine_Collection($table);
         $line = 0;
         foreach ($data as $source => $target) {
             ++$line;
             if (!is_string($source) || !is_string($target)) {
                 $this->getUser()->logError($this->getI18n()->__('Error line %line%: %file%', array('%line%' => $line, '%file%' => $file->getOriginalName())));
                 return $this->renderPartial('dmInterface/flash');
             } else {
                 $existing = $existQuery->fetchOneArray(array($catalogueId, $source));
                 if (!empty($existing) && $existing['source'] === $source) {
                     if ($existing['target'] !== $target) {
                         if ($override || $existing['created_at'] === $existing['updated_at']) {
                             $table->createQuery()->update('DmTransUnit')->set('target', '?', array($target))->where('id = ?', $existing['id'])->execute();
                             ++$nbUpdated;
                         }
                     }
                 } elseif (empty($existing)) {
                     $addedTranslations->add(dmDb::create('DmTransUnit', array('dm_catalogue_id' => $catalogue->get('id'), 'source' => $source, 'target' => $target)));
                     ++$nbAdded;
                 }
             }
         }
         $addedTranslations->save();
         if ($nbAdded) {
             $this->getUser()->logInfo($this->getI18n()->__('%catalogue%: added %count% translation(s)', array('%catalogue%' => $catalogue->get('name'), '%count%' => $nbAdded)));
         }
         if ($nbUpdated) {
             $this->getUser()->logInfo($this->getI18n()->__('%catalogue%: updated %count% translation(s)', array('%catalogue%' => $catalogue->get('name'), '%count%' => $nbUpdated)));
         }
         if (!$nbAdded && !$nbUpdated) {
             $this->getUser()->logInfo($this->getI18n()->__('%catalogue%: nothing to add and update', array('%catalogue%' => $catalogue->get('name'))));
         }
         return $this->renderText(url_for1($this->getRouteArrayForAction('index')));
     }
     $action = url_for1($this->getRouteArrayForAction('importSentences', $catalogue));
     return $this->renderText($form->render('.dm_form.list.little action="' . $action . '"'));
 }
开发者ID:theolymp,项目名称:diem,代码行数:60,代码来源:actions.class.php


示例7: getFirstMedia

 public function getFirstMedia()
 {
     if ($this->_invoker->contains($this->_options['mediaAlias'])) {
         return $this->_invoker->reference($this->_options['mediaAlias'])->getFirst();
     }
     return dmDb::query('DmMedia m, m.Folder f, m.' . $this->getGalleryRelClass() . ' rel')->where('rel.dm_record_id = ?', $this->_invoker->get('id'))->orderBy('rel.position ASC')->select('m.*, f.*')->fetchOne();
 }
开发者ID:Regmaya,项目名称:diem,代码行数:7,代码来源:DmGallery.php


示例8: getPage

 public function getPage()
 {
     if (null === $this->page) {
         $this->page = dmDb::table('DmPage')->findOneByIdWithI18n($this->pageId);
     }
     return $this->page;
 }
开发者ID:jdart,项目名称:diem,代码行数:7,代码来源:dmSearchPageHit.php


示例9: generateLayoutTemplates

 protected function generateLayoutTemplates()
 {
     $this->logSection('diem', 'generate layout templates');
     $filesystem = $this->get('filesystem');
     foreach (dmDb::query('DmLayout l')->fetchRecords() as $layout) {
         $template = $layout->get('template');
         $templateFile = dmProject::rootify('apps/front/modules/dmFront/templates/' . $template . 'Success.php');
         if (!file_exists($templateFile)) {
             if ($filesystem->mkdir(dirname($templateFile))) {
                 $filesystem->copy(dmOs::join(sfConfig::get('dm_front_dir'), 'modules/dmFront/templates/pageSuccess.php'), $templateFile);
                 $filesystem->chmod($templateFile, 0777);
             } else {
                 $this->logBlock('Can NOT create layout template ' . $template, 'ERROR');
             }
         }
     }
     $layoutFile = dmProject::rootify('apps/front/modules/dmFront/templates/layout.php');
     if (!file_exists($layoutFile)) {
         if ($filesystem->mkdir(dirname($layoutFile))) {
             $filesystem->copy(dmOs::join(sfConfig::get('dm_front_dir'), 'modules/dmFront/templates/layout.php'), $layoutFile);
             $filesystem->chmod($layoutFile, 0777);
         } else {
             $this->logBlock('Can NOT create layout ' . $layoutFile, 'ERROR');
         }
     }
 }
开发者ID:theolymp,项目名称:diem,代码行数:26,代码来源:dmFrontGenerateTask.class.php


示例10: createPageTranslations

 protected function createPageTranslations($pageId)
 {
     $cultures = $this->getOption('cultures');
     $translationTable = dmDb::table('DmPageTranslation');
     $existingCultures = $translationTable->createQuery('t')->where('t.id = ? ', $pageId)->andWhereIn('t.lang', $cultures)->select('t.lang')->fetchFlat();
     // can not generate translations from nothing
     if (empty($existingCultures)) {
         return;
     }
     // calculate missing cultures for this page
     $missingCultures = array_diff($cultures, $existingCultures);
     // all translations exist
     if (empty($missingCultures)) {
         return;
     }
     if (in_array(sfConfig::get('sf_default_culture'), $existingCultures)) {
         $mainCulture = sfConfig::get('sf_default_culture');
     } elseif (in_array(myDoctrineRecord::getDefaultCulture(), $existingCultures)) {
         $mainCulture = myDoctrineRecord::getDefaultCulture();
     } else {
         $mainCulture = dmArray::first($existingCultures);
     }
     $mainTranslationArray = $translationTable->createQuery('t')->select('t.slug, t.name, t.title, t.h1, t.description, t.keywords, t.is_active')->where('t.id = ?', $pageId)->andWhere('t.lang = ?', $mainCulture)->limit(1)->fetchOne(array(), Doctrine_Core::HYDRATE_ARRAY);
     $missingTranslations = new myDoctrineCollection(dmDb::table('DmPageTranslation'));
     if ($this->getOption('activate_new_translations')) {
         $isActive = $mainTranslationArray['is_active'];
     } else {
         $isActive = false;
     }
     foreach ($missingCultures as $culture) {
         $missingTranslations->add($translationTable->create(array_merge($mainTranslationArray, array('lang' => $culture, 'is_active' => $isActive))));
     }
     $missingTranslations->save();
 }
开发者ID:theolymp,项目名称:diem,代码行数:34,代码来源:dmPageI18nBuilder.php


示例11: execute

 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     throw new dmException('deprecated');
     $this->withDatabase();
     $page = dmDb::table('DmPage')->findOneByIdWithI18n($arguments['id'], $arguments['culture']);
     if (!$page instanceof DmPage) {
         throw new dmException('No page with id = ' . $arguments['id']);
     }
     $this->getContext()->setPage($page);
     $area = dmDb::query('DmArea a, a.Zones z, z.Widgets w')->select('a.id, z.id, w.module, w.action, w.value')->where('a.type = ? AND a.dm_page_view_id = ?', array('content', $page->get('PageView')->get('id')))->orderBy('z.position asc, w.position asc')->fetchArray();
     $widgetTypeManager = $dmContext->get('widget_type_manager');
     $html = '';
     foreach ($area[0]['Zones'] as $zone) {
         foreach ($zone['Widgets'] as $widget) {
             if (!in_array($widget['module'] . '.' . $widget['action'], self::$skipWidgets)) {
                 $widget['css_class'] = null;
                 $widgetViewClass = $widgetTypeManager->getWidgetType($widget['module'], $widget['action'])->getViewClass();
                 $widgetView = new $widgetViewClass($widget);
                 try {
                     $html .= $widgetView->toIndexableString();
                 } catch (Exception $e) {
                     $this->log($e->getMessage());
                 }
             }
         }
     }
     $indexableText = dmSearchIndex::cleanText($html);
     die($indexableText);
 }
开发者ID:theolymp,项目名称:diem,代码行数:32,代码来源:dmFrontPageIndexableContentTask.class.php


示例12: getQuery

 /**
  * Get the query for the pager.
  *
  * @return Doctrine_Query
  */
 public function getQuery()
 {
     if (dmDb::table($this->class)->hasI18n()) {
         return parent::getQuery()->withI18n();
     }
     return parent::getQuery();
 }
开发者ID:rafix,项目名称:diem,代码行数:12,代码来源:dmDoctrinePager.php


示例13: checkMissingAreas

 protected function checkMissingAreas()
 {
     foreach (self::getAreaTypes() as $type) {
         if (!$this->getArea($type)) {
             $this->get('Areas')->add(dmDb::create('DmArea', array('dm_layout_id' => $this->get('id'), 'type' => $type))->saveGet());
         }
     }
 }
开发者ID:jdart,项目名称:diem,代码行数:8,代码来源:PluginDmLayout.class.php


示例14: checkSearchPage

 /**
  * Check that search page exist
  * and, if doesn't, will create it
  */
 public function checkSearchPage()
 {
     if (!$this->createQuery('p')->where('p.module = ? AND p.action = ?', array('main', 'search'))->exists()) {
         $searchResultsPage = $this->create(array('name' => $this->tryToTranslate('Search results'), 'title' => $this->tryToTranslate('Search results'), 'module' => 'main', 'action' => 'search', 'slug' => 'search'));
         $searchResultsPage->getNode()->insertAsLastChildOf($this->getTree()->fetchRoot());
         dmDb::table('DmWidget')->createInZone($searchResultsPage->PageView->Area->Zones[0], 'dmWidgetSearch/results')->save();
     }
 }
开发者ID:Regmaya,项目名称:diem,代码行数:12,代码来源:PluginDmPageTable.class.php


示例15: executeShow

 public function executeShow()
 {
     $query = $this->getShowQuery('b');
     $this->branch = $this->getRecord($query);
     $this->tuto = dmDb::query('DocPage p')->withI18n()->leftJoin('p.Doc d')->where('d.type = ?', 'tuto')->orderBy('p.position ASC')->fetchOne();
     $this->howTo = dmDb::query('Doc d')->withI18n()->where('d.type = ?', 'howto')->fetchOne();
     $this->openSourceProjects = dmDb::query('DocPage p')->withI18n()->where('pTranslation.name = ?', 'Open source projects')->fetchOne();
 }
开发者ID:Regmaya,项目名称:diem-project,代码行数:8,代码来源:components.class.php


示例16: getUser

 public function getUser()
 {
     $userId = $this->get('user_id');
     if (!isset(self::$usersCache[$userId])) {
         self::$usersCache[$userId] = $userId ? dmDb::query('DmUser u')->where('u.id = ?', $userId)->fetchRecord() : null;
     }
     return self::$usersCache[$userId];
 }
开发者ID:jdart,项目名称:diem,代码行数:8,代码来源:dmRequestLogEntry.php


示例17: getGroupNames

 public function getGroupNames()
 {
     $groups = dmDb::query('DmSetting s')->select('s.group_name')->groupBy('s.group_name')->fetchPDO();
     foreach ($groups as $index => $group) {
         $groups[$index] = $group[0];
     }
     return $groups;
 }
开发者ID:theolymp,项目名称:diem,代码行数:8,代码来源:PluginDmSettingTable.class.php


示例18: executeTest

 public function executeTest()
 {
     $widget = dmDb::query('DmWidget q')->withI18n()->where('q.id = ?', 272)->fetchOne();
     $widgetValue = $widget->value;
     $widget = $widget->toArray();
     $widget['value'] = $widgetValue;
     $this->html = $this->getService('page_helper')->renderWidget($widget);
 }
开发者ID:Regmaya,项目名称:diem-project,代码行数:8,代码来源:components.class.php


示例19: fetchRecord

 protected function fetchRecord($model, $id)
 {
     $key = $model . ':' . $id;
     if (!isset(self::$recordsCache[$key])) {
         self::$recordsCache[$key] = dmDb::table($model)->createQuery('r')->where('r.id = ?', $id)->fetchRecord();
     }
     return self::$recordsCache[$key];
 }
开发者ID:theolymp,项目名称:diem,代码行数:8,代码来源:dmEventLogEntry.php


示例20: getLayout

 public function getLayout()
 {
     if (!($layout = $this->_get('Layout'))) {
         $layout = dmDb::table('DmLayout')->findFirstOrCreate();
         $this->set('Layout', $layout);
         $this->save();
     }
     return $layout;
 }
开发者ID:jdart,项目名称:diem,代码行数:9,代码来源:PluginDmPageView.class.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP dmOs类代码示例发布时间:2022-05-23
下一篇:
PHP dmArray类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap