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


PHP dmDb::create方法代码示例

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


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

示例1: backup

 /**
  * Store a copy of the file in backup folder
  */
 public function backup()
 {
     if (!($backupFolder = $this->getBackupFolder())) {
         throw new dmException(sprintf('Can not create backup folder for %s', $this));
     }
     $this->copyTo(dmDb::create('DmMedia')->set('Folder', $backupFolder))->save();
 }
开发者ID:theolymp,项目名称:diem,代码行数:10,代码来源:PluginDmMedia.class.php

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

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

示例4: findFirstOrCreate

 public function findFirstOrCreate()
 {
     if (null === $this->firstLayout || !$this->firstLayout->exists()) {
         if (!($this->firstLayout = $this->createQuery()->fetchRecord())) {
             $this->firstLayout = dmDb::create('DmLayout', array('name' => 'Global'))->saveGet();
         }
     }
     return $this->firstLayout;
 }
开发者ID:theolymp,项目名称:diem,代码行数:9,代码来源:PluginDmLayoutTable.class.php

示例5: save

 public function save(Doctrine_Connection $conn = null)
 {
     $wasNew = $this->isNew();
     $return = parent::save($conn);
     if ($wasNew && !$this->get('Zones')->count()) {
         dmDb::create('DmZone', array('dm_area_id' => $this->get('id')))->save();
         $this->refresh(true);
     }
 }
开发者ID:theolymp,项目名称:diem,代码行数:9,代码来源:PluginDmArea.class.php

示例6: setTemplate

 /**
  * Set a template to the mail
  *
  * @param mixed $templateName the template name, or a DmMailTemplateInstance
  * @return dmMail $this
  */
 public function setTemplate($templateName)
 {
     if ($templateName instanceof DmMailTemplate) {
         $this->template = $templateName;
     } elseif (!($this->template = dmDb::query('DmMailTemplate t')->where('t.name = ?', $templateName)->fetchRecord())) {
         $this->template = dmDb::create('DmMailTemplate', array('name' => $templateName));
     }
     return $this;
 }
开发者ID:jdart,项目名称:diem,代码行数:15,代码来源:dmMail.php

示例7: createMediaFromUploadedFile

 protected function createMediaFromUploadedFile(array &$values)
 {
     $file = $values['file'];
     $folder = dmDb::table('DmMediaFolder')->findOneByRelPathOrCreate('widget');
     $media = dmDb::table('DmMedia')->findOneByFileAndDmMediaFolderId(dmOs::sanitizeFileName($file->getOriginalName()), $folder->id);
     if (!$media) {
         $media = dmDb::create('DmMedia', array('dm_media_folder_id' => $folder->id))->create($file)->saveGet();
     }
     $values['mediaId'] = $media->id;
 }
开发者ID:theolymp,项目名称:diem,代码行数:10,代码来源:dmWidgetContentBaseMediaForm.php

示例8: addRate

 /**
  *
  * @return boolean true if ok, false else
  */
 public function addRate(array $rateData)
 {
     if ($rate = $this->getRatesQuery()->addWhere('dm_user_id = ?', $rateData['dm_user_id'])->fetchOne()) {
         $rate->rate = $rateData['rate'];
     } else {
         $rate = dmDb::create($this->getDmRatable()->getOption('className'), $rateData);
         $rate->id = $this->getInvoker()->id;
     }
     $rate->save();
 }
开发者ID:KnpLabs,项目名称:dmRatablePlugin,代码行数:14,代码来源:DmRatable.php

示例9: getArea

 public function getArea($type)
 {
     foreach ($this->get('Areas') as $area) {
         if ($area->get('type') == $type) {
             return $area;
         }
     }
     $area = dmDb::create('DmArea', array('dm_page_view_id' => $this->get('id'), 'type' => $type))->saveGet();
     $this->get('Areas')->add($area);
     return $area;
 }
开发者ID:theolymp,项目名称:diem,代码行数:11,代码来源:PluginDmPageView.class.php

示例10: createEmptyInstance

 /**
  * Creates an empty instance of the DmBehavior
  * 
  * @param string $key The behavior key
  * @param string $attachedTo On which container is attached, page, area, zone or widget?
  * @param int $attachedToId The id of the container
  * @param string $attachedToSelector If it is attached to the content
  * @return type 
  */
 public function createEmptyInstance($key, $attachedTo, $attachedToId, $attachedToSelector = null)
 {
     $formClass = $this->getBehaviorFormClass($key);
     $behavior = new DmBehavior();
     $behavior->setDmBehaviorKey($key);
     $form = new $formClass($behavior);
     $form->removeCsrfProtection();
     $position = dmDb::query('DmBehavior b')->orderBy('b.position desc')->limit(1)->select('MAX(b.position) as position')->fetchOneArray();
     $saveData = array('position' => $position['position'] + 1, 'dm_behavior_key' => $key, 'dm_behavior_attached_to' => $attachedTo, 'dm_' . $attachedTo . '_id' => (int) $attachedToId, 'dm_behavior_value' => json_encode($form->getDefaults()));
     if (!is_null($attachedToSelector)) {
         $saveData['dm_behavior_attached_to_selector'] = $attachedToSelector;
     }
     return dmDb::create('DmBehavior', $saveData)->saveGet();
 }
开发者ID:runopencode,项目名称:diem-extended,代码行数:23,代码来源:dmBehaviorsManager.class.php

示例11: storeInDb

 protected function storeInDb(dmErrorDescription $error)
 {
     dmDb::create('DmError', array('description' => $error->name . "\n" . $error->exception->getTraceAsString(), 'php_class' => $error->class, 'name' => dmString::truncate($error->name, 255, ''), 'module' => $error->module, 'action' => $error->action, 'uri' => $error->uri, 'env' => $error->env))->save();
 }
开发者ID:jdart,项目名称:diem,代码行数:4,代码来源:dmErrorWatcher.php

示例12: lime_test

$helper->boot();
$t = new lime_test(24);
$t->diag('default culture tests');
$user = $helper->get('user');
$userCulture = $user->getCulture();
$t->is(myDoctrineRecord::getDefaultCulture(), $user->getCulture(), 'default culture is ' . $user->getCulture());
$user->setCulture('en');
$t->is(myDoctrineRecord::getDefaultCulture(), $user->getCulture(), 'default culture is ' . $user->getCulture());
$user->setCulture('es');
$t->is(myDoctrineRecord::getDefaultCulture(), $user->getCulture(), 'default culture is ' . $user->getCulture());
$user->setCulture($userCulture);
$t->is(myDoctrineRecord::getDefaultCulture(), $user->getCulture(), 'default culture is ' . $user->getCulture());
$t->diag('Basic record tests');
$layout = dmDb::create('DmLayout', array('name' => dmString::random(), 'css_class' => 'the_class'))->saveGet();
$t->ok($layout instanceof DmLayout, 'call saveGet() returns the record');
$t->is(dmDb::create('DmLayout')->orNull(), null, 'call orNull() on new record returns null');
$t->is($layout->orNull(), $layout, 'call orNull() on existing record returns the record');
$t->diag('Property access tests');
$t->is($layout->get('css_class'), 'the_class', '->get("css_class")');
$t->is($layout->getCssClass(), 'the_class', '->getCssClass()');
$t->is($layout->css_class, 'the_class', '->css_class');
$t->is($layout->cssClass, 'the_class', '->cssClass');
$t->is($layout['cssClass'], 'the_class', '["css_class"]');
$t->ok($layout->set('css_class', 'other_class'), '->set("css_class")');
$t->ok($layout->setCssClass('other_class'), '->setCssClass()');
$t->ok($layout->css_class = 'other_class', '->css_class');
$t->ok($layout->cssClass = 'other_class', '->cssClass');
$layout->delete();
dmDb::table('DmPage')->checkBasicPages();
$page = dmDb::table('DmPage')->findOne();
$page->set('auto_mod', 'test');
开发者ID:theolymp,项目名称:diem,代码行数:31,代码来源:dmRecordTest.php

示例13: createWidget

 protected function createWidget($moduleAction, array $data, DmZone $zone)
 {
     list($module, $action) = explode('/', $moduleAction);
     $widgetType = $this->context->get('widget_type_manager')->getWidgetType($module, $action);
     $formClass = $widgetType->getOption('form_class');
     $form = new $formClass(dmDb::create('DmWidget', array('module' => $module, 'action' => $action, 'value' => '[]', 'dm_zone_id' => $zone->id)));
     $form->removeCsrfProtection();
     $form->bind(array_merge($form->getDefaults(), $data), array());
     if (!$form->isValid()) {
         throw $form->getErrorSchema();
     }
     return $form->updateWidget();
 }
开发者ID:theolymp,项目名称:diem,代码行数:13,代码来源:myTestProjectBuilder.php

示例14: foreach

$wtm = $helper->get('widget_type_manager');
$t->ok($wtm instanceof dmWidgetTypeManager, 'got an instanceof dmWidgetTypeManager');
$widgetTypes = $wtm->getWidgetTypes();
$t->ok(is_array($widgetTypes), 'got an array of widget types');
foreach ($widgetTypes as $moduleKey => $actions) {
    foreach ($actions as $actionKey => $widgetType) {
        $t->diag('Testing ' . $moduleKey . '.' . $actionKey . ' widget options, component, form and view');
        $fullKey = $moduleKey . ucfirst($actionKey);
        $t->is($widgetType->getFullKey(), $fullKey, 'full key is ' . $fullKey);
        try {
            $useComponent = $helper->get('controller')->componentExists($moduleKey, $actionKey);
        } catch (sfConfigurationException $e) {
            $useComponent = false;
        }
        $t->is($widgetType->useComponent(), $useComponent, $useComponent ? $fullKey . ' uses a component' : $fullKey . ' uses no component');
        $widget = dmDb::create('DmWidget', array('module' => $widgetType->getModule(), 'action' => $widgetType->getAction(), 'value' => '[]'));
        $formClass = $widgetType->getOption('form_class');
        try {
            $form = new $formClass($widget);
            $html = $form->render();
            $t->like($html, '_</form>$_', 'Successfully obtained and rendered a ' . $formClass . ' instance');
        } catch (Exception $e) {
            $t->fail('Successfully obtained and rendered a ' . $formClass . ' instance : ' . $e->getMessage());
        }
        $viewClass = $widgetType->getOption('view_class');
        try {
            $view = new $viewClass($helper->get('context'), $widgetType, $widget->toArrayWithMappedValue());
            sfConfig::set('sf_debug', false);
            $html = $view->render();
            sfConfig::set('sf_debug', true);
            $t->pass('Successfully obtained and rendered a ' . $viewClass . ' instance');
开发者ID:jdart,项目名称:diem,代码行数:31,代码来源:dmWidgetTypeManagerTest.php

示例15: createPage

 protected function createPage($module, $action, $name = null, $slug = null)
 {
     $name = $name ? $name : $module . '.' . $action;
     $slug = $slug ? $slug : dmString::slugify($name);
     return dmDb::create('DmPage', array('module' => $module, 'action' => $action, 'name' => $name, 'slug' => $slug));
 }
开发者ID:theolymp,项目名称:diem,代码行数:6,代码来源:dmPageUnitTestHelper.php


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