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


PHP xPDOObject::save方法代码示例

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


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

示例1: save

 /**
  * {@inheritdoc}
  * Create option values for product in category
  */
 public function save($cacheFlag = null)
 {
     $save = parent::save();
     /** @var xPDOQuery $q */
     $q = $this->xpdo->newQuery('msProduct', array('parent' => $this->get('category_id')));
     $q->select('id');
     if ($q->prepare() && $q->stmt->execute()) {
         $products = $q->stmt->fetchAll(PDO::FETCH_COLUMN);
         $value = $this->get('value');
         $key = $this->getOne('Option')->get('key');
         foreach ($products as $id) {
             $po = $this->xpdo->getObject('msProductOption', array('key' => $key, 'product_id' => $id));
             // дефолтные значения применяются только к тем товарам, у которых их еще нет
             if (!$po) {
                 /* @TODO вызывать метод msOption для поддержки множественных типов  */
                 $po = $this->xpdo->newObject('msProductOption');
                 $po->set('product_id', $id);
                 $po->set('key', $key);
                 $po->set('value', $value);
                 $po->save();
             }
         }
     }
     return $save;
 }
开发者ID:rafull6,项目名称:texno-service,代码行数:29,代码来源:mscategoryoption.class.php

示例2: save

 /**
  * Overrides xPDOObject::save to set a default created time if new.
  *
  * @param boolean $cacheFlag
  * @return boolean True if the save was successful
  */
 public function save($cacheFlag= null) {
     if ($this->_new && !$this->get('created')) {
         $this->set('created', strftime('%Y-%m-%d %H:%M:%S'));
     }
     $saved= parent :: save($cacheFlag);
     return $saved;
 }
开发者ID:raf3600,项目名称:revolution,代码行数:13,代码来源:modtransportpackage.class.php

示例3: save

 /**
  * @param null $cacheFlag
  *
  * @return bool
  */
 public function save($cacheFlag = null)
 {
     $new = $this->isNew();
     $class = $this->get('class');
     $save = parent::save($cacheFlag);
     if ($new) {
         $type = '';
         $ticket_id = 0;
         if ($class == 'TicketComment') {
             $type = 'vote_comment';
             /** @var TicketComment $comment */
             if ($comment = $this->xpdo->getObject('TicketComment', $this->id)) {
                 /** @var TicketThread $comment */
                 if ($thread = $comment->getOne('Thread')) {
                     $ticket_id = $thread->get('resource');
                 }
             }
         } elseif ($class == 'Ticket') {
             $type = 'vote_ticket';
             $ticket_id = $this->id;
         }
         if (!empty($type) && !empty($ticket_id)) {
             $multiplier = $this->get('value');
             /** @var TicketAuthor $profile */
             if ($profile = $this->xpdo->getObject('TicketAuthor', $this->get('owner'))) {
                 $profile->addAction($type, $this->id, $ticket_id, $multiplier);
             }
         }
     }
     return $save;
 }
开发者ID:soulcreate,项目名称:Tickets,代码行数:36,代码来源:ticketvote.class.php

示例4: prepareRow

 public function prepareRow(xPDOObject $object)
 {
     $object->set('encrypted', 0);
     $object->set('values', $this->modx->toJSON($object->decrypt()));
     $object->save();
     $ff = $object->toArray();
     return $ff;
 }
开发者ID:raadhuis,项目名称:modx-basic,代码行数:8,代码来源:decrypt.class.php

示例5: save

 public function save($cacheFlag = null)
 {
     $saved = parent::save($cacheFlag);
     if ($saved) {
         $this->clearCache();
     }
     return $saved;
 }
开发者ID:semencov-com,项目名称:affiliate,代码行数:8,代码来源:modsystemsetting.class.php

示例6: save

 /**
  * Overrides xPDOObject::save to clear lexicon cache on saving.
  *
  * {@inheritdoc}
  */
 public function save($cacheFlag = null)
 {
     $saved = parent::save($cacheFlag);
     if ($saved && empty($this->xpdo->config[xPDO::OPT_SETUP])) {
         $this->clearCache();
     }
     return $saved;
 }
开发者ID:JoeBlow,项目名称:revolution,代码行数:13,代码来源:modlexiconlanguage.class.php

示例7: save

 public function save($cacheFlag = null)
 {
     $saved = parent::save();
     if ($saved && !$this->getOption(xPDO::OPT_SETUP)) {
         $this->xpdo->call('modNamespace', 'clearCache', array(&$this->xpdo));
     }
     return $saved;
 }
开发者ID:adamwintle,项目名称:flexibility5,代码行数:8,代码来源:modnamespace.class.php

示例8: prepareRow

 public function prepareRow(xPDOObject $object)
 {
     $object->set('encrypted', 1);
     $values = $object->get('values');
     $object->set('values', $object->encrypt($values));
     $object->save();
     $ff = $object->toArray();
     return $ff;
 }
开发者ID:raadhuis,项目名称:modx-basic,代码行数:9,代码来源:encrypt.class.php

示例9: save

 /**
  * @param null $cacheFlag
  *
  * @return bool
  */
 public function save($cacheFlag = null)
 {
     $time = time();
     $this->set('createdon', $time);
     $this->set('year', date('Y', $time));
     $this->set('month', date('m', $time));
     $this->set('day', date('d', $time));
     return parent::save($cacheFlag);
 }
开发者ID:soulcreate,项目名称:Tickets,代码行数:14,代码来源:ticketauthoraction.class.php

示例10: save

 /** {@inheritdoc} */
 public function save($cacheFlag = null)
 {
     if ($this->isNew()) {
         $ip = $this->xpdo->request->getClientIp();
         $this->set('registration', time());
         $this->set('lastactivity', time());
         $this->set('type', $this->xpdo->userprofile2->getProfileTypeDefault());
         $this->set('ip', $ip['ip']);
     }
     return parent::save($cacheFlag);
 }
开发者ID:arimanr,项目名称:userprofile2,代码行数:12,代码来源:up2profile.class.php

示例11: save

 /**
  * Overrides xPDOObject::save to fire modX-specific events.
  * 
  * {@inheritDoc}
  */
 public function save($cacheFlag = null)
 {
     $isNew = $this->isNew();
     if ($this->xpdo instanceof modX) {
         $this->xpdo->invokeEvent('OnPluginEventBeforeSave', array('mode' => $isNew ? modSystemEvent::MODE_NEW : modSystemEvent::MODE_UPD, 'pluginEvent' => &$this, 'cacheFlag' => $cacheFlag));
     }
     $saved = parent::save($cacheFlag);
     if ($saved && $this->xpdo instanceof modX) {
         $this->xpdo->invokeEvent('OnPluginEventSave', array('mode' => $isNew ? modSystemEvent::MODE_NEW : modSystemEvent::MODE_UPD, 'pluginEvent' => &$this, 'cacheFlag' => $cacheFlag));
     }
     return $saved;
 }
开发者ID:JoeBlow,项目名称:revolution,代码行数:17,代码来源:modpluginevent.class.php

示例12: save

 /**
  * @param null $cacheFlag
  *
  * @return bool
  */
 public function save($cacheFlag = null)
 {
     $new = $this->isNew();
     $parent = parent::save($cacheFlag);
     if ($new && ($uid = $this->get('uid'))) {
         /** @var TicketAuthor $profile */
         if ($profile = $this->xpdo->getObject('TicketAuthor', $uid)) {
             $profile->addAction('view', $this->get('parent'), $this->get('parent'));
         }
     }
     return $parent;
 }
开发者ID:soulcreate,项目名称:Tickets,代码行数:17,代码来源:ticketview.class.php

示例13: process

 /**
  * {@inheritDoc}
  * @return mixed
  */
 public function process()
 {
     /* Run the beforeSet method before setting the fields, and allow stoppage */
     $canSave = $this->beforeSet();
     if ($canSave !== true) {
         return $this->failure($canSave);
     }
     $this->newObject->fromArray($this->object->toArray());
     $name = $this->getNewName();
     $this->setNewName($name);
     if ($this->alreadyExists($name)) {
         $this->addFieldError($this->nameField, $this->modx->lexicon($this->objectType . '_err_ae', array('name' => $name)));
     }
     $canSave = $this->beforeSave();
     if ($canSave !== true) {
         return $this->failure($canSave);
     }
     /* save new chunk */
     if ($this->newObject->save() === false) {
         $this->modx->error->checkValidation($this->newObject);
         return $this->failure($this->modx->lexicon($this->objectType . '_err_duplicate'));
     }
     $this->afterSave();
     $this->logManagerAction();
     return $this->cleanup();
 }
开发者ID:e-gob,项目名称:apps.gob.cl,代码行数:30,代码来源:modprocessor.class.php

示例14: save

 /**
  * Custom save that respects access policies.
  *
  * {@inheritdoc}
  */
 public function save($cacheFlag = null)
 {
     $saved = false;
     if (!$this->checkPolicy('save')) {
         $this->xpdo->error->failure($this->xpdo->lexicon('permission_denied'));
     }
     $saved = parent::save($cacheFlag);
     return $saved;
 }
开发者ID:JoeBlow,项目名称:revolution,代码行数:14,代码来源:modaccessibleobject.class.php

示例15: prepareRow

 /**
  * Prepare the row for iteration
  * @param xPDOObject $object
  * @return array
  */
 public function prepareRow(xPDOObject $object)
 {
     $objectArray = $object->toArray();
     $value = $objectArray['value'];
     $value = str_replace(',', '||', $value);
     $values = array_map('trim', @explode('||', $value));
     if (!empty($values)) {
         $valuesArray = array();
         foreach ($values as $value) {
             if (empty($value)) {
                 continue;
             }
             $valuesArray[] = $value;
             $tag = $this->modx->getObject('smarttagTags', array('tag:LIKE' => $value));
             if (!$tag) {
                 $tag = $this->modx->newObject('smarttagTags');
                 $tag->set('tag', $value);
                 if ($tag->save() === false) {
                     $this->modx->log(modX::LOG_LEVEL_ERROR, __LINE__ . ': Error on saving new tag data: ' . $value);
                     continue;
                 }
             }
             $params = array('tag_id' => $tag->getPrimaryKey(), 'tmplvar_id' => $objectArray['tmplvarid'], 'resource_id' => $objectArray['contentid']);
             $smarttagTagresource = $this->modx->getObject('smarttagTagresources', $params);
             if (!$smarttagTagresource) {
                 $smarttagTagresource = $this->modx->newObject('smarttagTagresources');
                 $smarttagTagresource->fromArray($params, NULL, TRUE, TRUE);
                 if ($smarttagTagresource->save() === false) {
                     $this->modx->log(modX::LOG_LEVEL_ERROR, __LINE__ . ': Error on saving new tag resource data: ' . print_r($params, 1));
                     continue;
                 }
                 $this->_count++;
             }
         }
         $valuesArray = array_unique($valuesArray);
         if (!empty($valuesArray)) {
             $newValue = @implode('||', $valuesArray);
             if ($objectArray['value'] !== $newValue) {
                 $object->set('value', $newValue);
                 if ($object->save()) {
                     $objectArray['value'] = $newValue;
                 }
             }
         }
     }
     return $objectArray;
 }
开发者ID:ExcaliburKG,项目名称:SmartTag,代码行数:52,代码来源:sync.class.php


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