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


PHP AppModel::save方法代码示例

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


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

示例1: save

 function save($data)
 {
     if (empty($data['Origin']) && !Set::numeric(array_keys($data))) {
         $data = array('Origin' => $data);
     }
     $key = null;
     if (!empty($data['Origin']['link'])) {
         $key = md5($data['Origin']['link']);
         if (!empty($this->__cache[$key])) {
             return $this->__cache[$key];
         }
     }
     if (empty($data['Origin']['id']) && !empty($data['Origin']['provider_key'])) {
         $found = parent::find('first', array('conditions' => array('Origin.provider_key' => $data['Origin']['provider_key'])));
         if ($found) {
             unset($found['Origin']['modified']);
             $this->set($found);
         }
     }
     $this->set($data);
     $result = parent::save();
     $result['Origin']['id'] = $this->id;
     if ($key) {
         $this->__cache[$key] = $result;
     }
     return $result;
 }
开发者ID:rchavik,项目名称:20Couch,代码行数:27,代码来源:origin.php

示例2: save

 /**
  * Saves model data (based on white-list, if supplied) to the database. By
  * default, validation occurs before save. Passthrough method to _doSave() with
  * transaction handling.
  *
  * @param array $data Data to save.
  * @param bool|array $validate Either a boolean, or an array.
  *   If a boolean, indicates whether or not to validate before saving.
  *   If an array, can have following keys:
  *
  *   - atomic: If true (default), will attempt to save the record in a single transaction.
  *   - validate: Set to true/false to enable or disable validation.
  *   - fieldList: An array of fields you want to allow for saving.
  *   - callbacks: Set to false to disable callbacks. Using 'before' or 'after'
  *     will enable only those callbacks.
  *   - `counterCache`: Boolean to control updating of counter caches (if any)
  *
  * @param array $fieldList List of fields to allow to be saved
  * @return mixed On success Model::$data if its not empty or true, false on failure
  * @throws Exception
  * @throws PDOException
  * @triggers Model.beforeSave $this, array($options)
  * @triggers Model.afterSave $this, array($created, $options)
  * @link http://book.cakephp.org/2.0/en/models/saving-your-data.html
  * @SuppressWarnings(PHPMD.BooleanArgumentFlag)
  */
 public function save($data = null, $validate = true, $fieldList = array())
 {
     if ($this->useTable) {
         return parent::save($data, $validate, $fieldList);
     }
     if ($data) {
         $this->set($data);
     }
     $defaults = array('validate' => true, 'fieldList' => array(), 'callbacks' => true, 'counterCache' => true, 'atomic' => true);
     if (!is_array($validate)) {
         $options = compact('validate', 'fieldList') + $defaults;
     } else {
         $options = $validate + $defaults;
     }
     if ($options['callbacks'] === true || $options['callbacks'] === 'before') {
         $event = new CakeEvent('Model.beforeSave', $this, array($options));
         list($event->break, $event->breakOn) = array(true, array(false, null));
         $this->getEventManager()->dispatch($event);
         if (!$event->result) {
             //$this->whitelist = $_whitelist;
             return false;
         }
     }
     if ($options['callbacks'] === true || $options['callbacks'] === 'after') {
         $event = new CakeEvent('Model.afterSave', $this, array(false, $options));
         $this->getEventManager()->dispatch($event);
     }
 }
开发者ID:akagane99,项目名称:Blocks,代码行数:54,代码来源:BlockBaseModel.php

示例3: save

 /**
  * Overwrite save to write to the datasource defined in config
  *
  * {@inheritDoc}
  */
 public function save($data = null, $validate = true, $fieldList = array())
 {
     $this->setDataSourceWrite();
     $retval = parent::save($data, $validate, $fieldList);
     $this->setDataSourceRead();
     return $retval;
 }
开发者ID:simaostephanie,项目名称:CakePHP-DatabaseLog,代码行数:12,代码来源:DatabaseLogAppModel.php

示例4: save

 function save($data)
 {
     App::import('Model', 'AccountingBukuBesar');
     App::import('Model', 'AccountingAccount');
     $bukubesar = new AccountingBukuBesar();
     $account = new AccountingAccount();
     //$type = $this->AccountingTransactionType
     //			->findById($data['AccountingTransaction']['accounting_transaction_type_id']);
     //$data['AccountingTransaction']['account_debit_id'] = $type['AccountingTransactionType']['account_debit_id'];
     //$data['AccountingTransaction']['account_credit_id'] = $type['AccountingTransactionType']['account_credit_id'];
     if (parent::save($data)) {
         $bukus = array(array('AccountingBukuBesar' => array('accounting_account_id' => $data['AccountingTransaction']['account_debit_id'], 'accounting_transaction_id' => $this->id, 'estimates' => 'DEBIT', 'amount' => $data['AccountingTransaction']['amount'], 'debit' => $data['AccountingTransaction']['amount'], 'credit' => 0)), array('AccountingBukuBesar' => array('accounting_account_id' => $data['AccountingTransaction']['account_credit_id'], 'accounting_transaction_id' => $this->id, 'estimates' => 'CREDIT', 'amount' => $data['AccountingTransaction']['amount'], 'debit' => 0, 'credit' => $data['AccountingTransaction']['amount'])));
         foreach ($bukus as $buku) {
             $b = $bukubesar->find('all', array('conditions' => array('AccountingBukuBesar.accounting_transaction_id' => $buku['AccountingBukuBesar']['accounting_transaction_id'], 'AccountingBukuBesar.estimates' => $buku['AccountingBukuBesar']['estimates'])));
             if (count($b) === 0) {
                 $bukubesar->create();
             } else {
                 $bukubesar->id = $b[0]['AccountingBukuBesar']['id'];
             }
             $bukubesar->save($buku);
             $parent = $account->read(null, $buku['AccountingBukuBesar']['accounting_account_id']);
             if ($parent['AccountingAccount']['parent_id'] == 14) {
                 $bukubesar->create();
                 $bukubesar->save(array('AccountingBukuBesar' => array('accounting_account_id' => 18, 'accounting_transaction_id' => $this->id, 'estimates' => 'DEBIT', 'amount' => $buku['AccountingBukuBesar']['amount'], 'debit' => $buku['AccountingBukuBesar']['amount'], 'credit' => 0)));
             }
             if ($parent['AccountingAccount']['parent_id'] == 2) {
                 $bukubesar->create();
                 $bukubesar->save(array('AccountingBukuBesar' => array('accounting_account_id' => 18, 'accounting_transaction_id' => $this->id, 'estimates' => 'CREDIT', 'amount' => $buku['AccountingBukuBesar']['amount'], 'debit' => 0, 'credit' => $buku['AccountingBukuBesar']['amount'])));
             }
         }
         return true;
     } else {
         return false;
     }
 }
开发者ID:javan-it-services,项目名称:internal,代码行数:35,代码来源:accounting_transaction.php

示例5: save

 /** save */
 public function save($dao)
 {
     if (!isset($dao->date) || empty($dao->date)) {
         $dao->setDate(date('Y-m-d H:i:s'));
     }
     parent::save($dao);
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:8,代码来源:BitstreamModelBase.php

示例6: save

 function save($data)
 {
     $this->Origin->create();
     $origin = $this->Origin->save($data['Origin']);
     if (!empty($data['ForwardOrigin'])) {
         $this->Origin->create();
         $forwardOrigin = $this->Origin->save($data['ForwardOrigin']);
     }
     if ($this->Origin->isMuted($origin, $data['Item']['posted'])) {
         $data['Item']['read'] = true;
     }
     $data['Item']['origin_id'] = $origin['Origin']['id'];
     if (!empty($forwardOrigin)) {
         $data['Item']['forward_origin_id'] = $forwardOrigin['Origin']['id'];
     }
     if (empty($data['Item']['id']) && !empty($data['Item']['provider_id']) && !empty($data['Item']['provider_key'])) {
         $found = parent::find('first', array('conditions' => array('Item.provider_id' => $data['Item']['provider_id'], 'Item.provider_key' => $data['Item']['provider_key'])));
         if ($found) {
             $this->set($found);
         }
     }
     $this->set($data['Item']);
     $data = parent::save();
     $data['Item']['id'] = $this->id;
     $data['Origin'] = $origin['Origin'];
     return $data;
 }
开发者ID:rchavik,项目名称:20Couch,代码行数:27,代码来源:item.php

示例7: save

 /** save */
 public function save($dao)
 {
     if (!isset($dao->uuid) || empty($dao->uuid)) {
         /** @var UuidComponent $uuidComponent */
         $uuidComponent = MidasLoader::loadComponent('Uuid');
         $dao->setUuid($uuidComponent->generate());
     }
     parent::save($dao);
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:10,代码来源:UserModelBase.php

示例8: save

 public function save($data, $validate = true, $fieldList = false)
 {
     $saved = parent::save($data, $validate, $fieldList);
     if ($saved) {
         Cache::delete($this->_key($this->id));
         $this->findCached($this->id, true);
     }
     return $saved;
 }
开发者ID:predominant,项目名称:CakeMatsuri-Todo,代码行数:9,代码来源:item.php

示例9: sess_regenerate

function sess_regenerate()
{
    $oldSessionID = session_id();
    if (isset($_COOKIE[session_name()])) {
        setcookie(session_name(), '', time() - 42000, '/');
    }
    session_regenerate_id();
    $Session = new AppModel('Session');
    $Session->save(array('id' => session_id()), $oldSessionID);
}
开发者ID:nowk,项目名称:baseapp-framework,代码行数:10,代码来源:session_helper.php

示例10: save

 public function save($data = array())
 {
     if (empty($this->id)) {
         if ($data['CanteenOrder']) {
             $data['CanteenOrder']['id'] = $this->genId();
             $data['CanteenOrder']['hash'] = sha1($data['CanteenOrder']['id']);
         } else {
             $data['id'] = $this->genId();
             $data['hash'] = sha1($data['id']);
         }
     }
     return parent::save($data);
 }
开发者ID:josephbergdoll,项目名称:berrics,代码行数:13,代码来源:CanteenOrder.php

示例11: save

 public function save($data = array())
 {
     if (empty($this->id)) {
         if (isset($data['CanteenShippingRecord'])) {
             $data['CanteenShippingRecord']['id'] = $this->genId();
             $data['CanteenShippingRecord']['hash'] = md5($data['CanteenShippingRecord']['id']);
         } else {
             $data['id'] = $this->genId();
             $data['hash'] = md5($data['id']);
         }
     }
     return parent::save($data);
 }
开发者ID:josephbergdoll,项目名称:berrics,代码行数:13,代码来源:CanteenShippingRecord.php

示例12: saveAll

 function saveAll($data)
 {
     $fixedData = array();
     $settings = $this->find('list', array('fields' => array('Setting.key', 'Setting.id')));
     foreach ($data['Setting'] as $key => $value) {
         if (!empty($settings[$key])) {
             $fixedData = array('id' => $settings[$key], 'key' => trim($key), 'value' => trim($value));
             if (!parent::save($fixedData)) {
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:rchavik,项目名称:20Couch,代码行数:14,代码来源:setting.php

示例13: save

 /** save */
 public function save($dao)
 {
     if (!isset($dao->uuid) || empty($dao->uuid)) {
         /** @var UuidComponent $uuidComponent */
         $uuidComponent = MidasLoader::loadComponent('Uuid');
         $dao->setUuid($uuidComponent->generate());
     }
     $name = $dao->getName();
     if (empty($name) && $name !== '0') {
         throw new Zend_Exception('Please set a name for the Community.');
     }
     $cleanDescription = UtilityComponent::filterHtmlTags($dao->getDescription());
     $dao->setDescription($cleanDescription);
     parent::save($dao);
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:16,代码来源:CommunityModelBase.php

示例14: save

 function save($data = null, $validate = true, $fieldList = array())
 {
     // Changing this because simpletest always send image as 'application/octet-stream'
     if (isset($data['Meio']['filename']['type'])) {
         switch (substr($data['Meio']['filename']['name'], -4)) {
             case '.jpg':
             case '.jpeg':
                 $data['Meio']['filename']['type'] = 'image/jpeg';
                 break;
             case '.png':
                 $data['Meio']['filename']['type'] = 'image/png';
                 break;
             case '.gif':
                 $data['Meio']['filename']['type'] = 'image/gif';
                 break;
         }
     }
     return parent::save($data, $validate, $fieldList);
 }
开发者ID:johnulist,项目名称:adrotator,代码行数:19,代码来源:meio.php

示例15: save

 function save($data = null, $validate = true, $fieldList = array())
 {
     $buySeatsDone = true;
     $buyTicketsDone = true;
     $this->begin();
     if (parent::save($data, $validate)) {
         if (isset($data['BuyTicket'])) {
             $this->BuyTicket->delete(array('BuyTicket.buy_id' => $this->id));
             foreach ($data['BuyTicket'] as $key => $ticket) {
                 if ($ticket['qty'] > 0) {
                     $ticket['buy_id'] = $this->id;
                     $this->BuyTicket->create();
                     if (!$this->BuyTicket->save($ticket)) {
                         $buyTicketsDone = false;
                     }
                 } else {
                     unset($data['BuyTicket'][$key]);
                 }
             }
         }
         if (isset($data['BuySeat'])) {
             $this->BuySeat->delete(array('BuySeat.buy_id' => $this->id));
             foreach ($data['BuySeat'] as $seat) {
                 $seat['buy_id'] = $this->id;
                 $this->BuySeat->create();
                 if (!$this->BuySeat->save($seat)) {
                     $buySeatsDone = false;
                 }
             }
         }
         if (!$buySeatsDone || !$buyTicketsDone) {
             $this->rollback();
             return false;
         }
     }
     $this->commit();
     return true;
 }
开发者ID:roae,项目名称:hello-world,代码行数:38,代码来源:buy.php


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