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


PHP Doctrine_Record::save方法代码示例

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


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

示例1: save

 public function save()
 {
     $identifier = $this->identifier();
     $identifier = implode(', ', $identifier);
     // If column aggregation is used on this model we will have $class_type defined. Ensure it's set model is loaded
     if (!empty($this->class_type)) {
         Doctrine::initializeModels($this->class_type);
     }
     $identifier = $this->identifier();
     $identifier = implode(', ', $identifier);
     // Look for Kohana errors, and if they exist, throw Bluebox_Validation_Exception
     if (count(Bluebox_Controller::$validation->field_names()) > 0 and Bluebox_Controller::$validation->validate() == FALSE) {
         Kohana::log('debug', 'Kohana validation failed while saving ' . get_class($this) . ' ' . $identifier, 1);
         throw new Bluebox_Validation_Exception('Kohana validation failed on ' . get_class($this) . ' ' . $identifier, 1);
         // re-throw
     }
     try {
         // Store only the first record in this save event, making it available for any events that may need to know who started the save
         if (!self::getBaseTransactionObject()) {
             self::setBaseSaveObject($this);
             $invalid = $this->checkValidation();
             if (!empty($invalid)) {
                 throw new Doctrine_Validator_Exception($invalid);
             }
         }
         parent::save();
         // Done with any events that may use this
         if (self::getBaseTransactionObject() == $this) {
             self::setBaseSaveObject(NULL);
         }
         Kohana::log('debug', 'Saved record ' . get_class($this) . ' ' . $identifier);
         return TRUE;
     } catch (Doctrine_Validator_Exception $e) {
         Kohana::log('error', 'Doctrine_Validator_Exception on record ' . get_class($this) . ' ' . $identifier . ': ' . $e->getMessage());
         self::normalizeErrors($e);
         return FALSE;
     } catch (Doctrine_Transaction_Exception $e) {
         Kohana::log('error', 'Doctrine_Transaction_Exception on record ' . get_class($this) . ' ' . $identifier . ': ' . $e->getMessage());
         self::setBaseSaveObject(NULL);
         throw new Doctrine_Transaction_Exception($e->getMessage());
         return FALSE;
     } catch (Doctrine_Connection_Exception $e) {
         Kohana::log('error', 'Doctrine_Connection_Exception on record ' . get_class($this) . ' ' . $identifier . ': ' . $e->getMessage());
         self::setBaseSaveObject(NULL);
         throw new Doctrine_Connection_Exception($e->getMessage());
         return FALSE;
     } catch (Exception $e) {
         Kohana::log('error', 'Unhandled ' . get_class($e) . ' on record ' . get_class($this) . ' ' . $identifier . ': ' . $e->getMessage());
         self::setBaseSaveObject(NULL);
         throw new Exception($e->getMessage());
         return FALSE;
     }
 }
开发者ID:Jaybee-,项目名称:bluebox,代码行数:53,代码来源:Bluebox_Record.php

示例2: rec_update

 /**
  * Update
  *
  * @param Doctrine_Record $logo
  * @param array   $data
  * @return string $uuid
  */
 protected function rec_update($logo, $data)
 {
     $this->check_authz($logo->Inquiry, 'write');
     $this->require_data($data, array('logo'));
     try {
         $logo->set_image($data['logo']);
     } catch (Exception $e) {
         throw new Rframe_Exception(RFrame::BAD_DATA, $e->getMessage());
     }
     // save
     $logo->save();
     return $logo->img_uuid;
 }
开发者ID:kaakshay,项目名称:audience-insight-repository,代码行数:20,代码来源:logo.php

示例3: swapWith

 public function swapWith(Doctrine_Record $record2)
 {
     $record1 = $this->getInvoker();
     $many = $this->_options['manyListsColumn'];
     if (!empty($many)) {
         if ($record1->{$many} != $record2->{$many}) {
             throw new Doctrine_Record_Exception('Cannot swap items from different lists.');
         }
     }
     $conn = $this->getTable()->getConnection();
     $conn->beginTransaction();
     $pos1 = $record1->position;
     $pos2 = $record2->position;
     $record1->position = $pos2;
     $record2->position = $pos1;
     $record1->save();
     $record2->save();
     $conn->commit();
 }
开发者ID:saadtazi,项目名称:Continue-this-Story,代码行数:19,代码来源:Sortable.php

示例4: swapWith

 public function swapWith(Doctrine_Record $object2)
 {
     $object1 = $this->getInvoker();
     $fieldName = $this->_options['name'];
     foreach ($this->_options['parents'] as $col) {
         if ($object1->{$col} != $object2->{$col}) {
             throw new Doctrine_Record_Exception('Cannot swap items from different lists.');
         }
     }
     $conn = $this->getTable()->getConnection();
     $conn->beginTransaction();
     $pos1 = $object1->{$fieldName};
     $pos2 = $object2->{$fieldName};
     $object1->{$fieldName} = $pos2;
     $object2->{$fieldName} = $pos1;
     $object1->save();
     $object2->save();
     $conn->commit();
 }
开发者ID:nicolasmartin,项目名称:framework,代码行数:19,代码来源:SortableBehavior.php

示例5: swapWith

 public function swapWith(Doctrine_Record $record2)
 {
     $record1 = $this->getInvoker();
     $name = $this->getName();
     foreach ($this->_options['manyListsBy'] as $col) {
         if ($record1->{$col} != $record2->{$col}) {
             throw new Doctrine_Record_Exception('Cannot swap items from different lists.');
         }
     }
     $conn = $this->getTable()->getConnection();
     $conn->beginTransaction();
     $pos1 = $record1->{$name};
     $pos2 = $record2->{$name};
     $record1->{$name} = $pos2;
     $record2->{$name} = $pos1;
     $record1->save();
     $record2->save();
     $conn->commit();
 }
开发者ID:jdudek,项目名称:doctrine-sortable,代码行数:19,代码来源:Sortable.php

示例6: _saveEntity

 /**
  * Method to save entity. May be refined in child controller
  *
  * @param Doctrine_Record $entity
  * @param Zend_Form $form
  * @return void
  */
 protected function _saveEntity(Doctrine_Record $entity, Zend_Form $form)
 {
     $entity->merge($form->getValues());
     $entity->save();
 }
开发者ID:prosalov,项目名称:zf1-code-example,代码行数:12,代码来源:Crud.php

示例7: saveRecord

 public function saveRecord()
 {
     $this->_record->save();
 }
开发者ID:lciolecki,项目名称:zf-doctrine,代码行数:4,代码来源:Doctrine.php

示例8: save

 /**
  * Save the changes
  *
  * @return void
  */
 public function save()
 {
     $this->_dbRecord->save();
 }
开发者ID:EricHogue,项目名称:Koryukan,代码行数:9,代码来源:Base.php

示例9: update

 /**
  * update
  * updates the given record
  *
  * @param Doctrine_Record $record   record to be updated
  * @return boolean                  whether or not the update was successful
  */
 public function update(Doctrine_Record $record)
 {
     $event = new Doctrine_Event($this, Doctrine_Event::RECORD_UPDATE);
     $record->preUpdate($event);
     if (!$event->skipOperation) {
         $array = $record->getPrepared();
         if (empty($array)) {
             return false;
         }
         $set = array();
         foreach ($array as $name => $value) {
             if ($value instanceof Doctrine_Expression) {
                 $set[] = $value->getSql();
                 unset($array[$name]);
             } else {
                 $set[] = $name . ' = ?';
                 if ($value instanceof Doctrine_Record) {
                     if (!$value->exists()) {
                         $record->save($this->conn);
                     }
                     $array[$name] = $value->getIncremented();
                     $record->set($name, $value->getIncremented());
                 }
             }
         }
         $params = array_values($array);
         $id = $record->identifier();
         if (!is_array($id)) {
             $id = array($id);
         }
         $id = array_values($id);
         $params = array_merge($params, $id);
         $sql = 'UPDATE ' . $this->conn->quoteIdentifier($record->getTable()->getTableName()) . ' SET ' . implode(', ', $set) . ' WHERE ' . implode(' = ? AND ', $record->getTable()->getPrimaryKeys()) . ' = ?';
         $stmt = $this->conn->getDbh()->prepare($sql);
         $stmt->execute($params);
         $record->assignIdentifier(true);
     }
     $record->postUpdate($event);
     return true;
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:47,代码来源:UnitOfWork.php

示例10: save

 /**
  * Save the record to the database
  *
  * @param object  $conn (optional)
  */
 public function save(Doctrine_Connection $conn = null)
 {
     // unless explicitly passed, we find the _master connection
     // for the current env.
     if ($conn === null) {
         $conn = AIR2_DBManager::get_master_connection();
     }
     parent::save($conn);
 }
开发者ID:kaakshay,项目名称:audience-insight-repository,代码行数:14,代码来源:AIR2_Record.php

示例11: air_save

 /**
  * Calls ->save() on $rec, wrapped in a try/catch,
  * and re-throws any exception as a Rframe_Exception.
  *
  * @param Doctrine_Record  $rec
  */
 public function air_save(Doctrine_Record $rec)
 {
     try {
         $rec->save();
         $this->update_parent($rec);
     } catch (Exception $e) {
         // rethrow as Rframe exception
         //Carper::carp("caught save() exception: $e");
         throw new Rframe_Exception(Rframe::BAD_DATA, $e->getMessage());
     }
 }
开发者ID:kaakshay,项目名称:audience-insight-repository,代码行数:17,代码来源:AIRAPI_Resource.php


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