本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例5: save
public function save($cacheFlag = null)
{
$saved = parent::save($cacheFlag);
if ($saved) {
$this->clearCache();
}
return $saved;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}