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


PHP Doctrine_Record::set方法代码示例

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


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

示例1: fetchRelatedFor

    /**
     * fetchRelatedFor
     *
     * fetches a component related to given record
     *
     * @param Doctrine_Record $record
     * @return Doctrine_Record|Doctrine_Collection
     */
    public function fetchRelatedFor(Doctrine_Record $record)
    {
        $localFieldName = $record->getTable()->getFieldName($this->definition['local']);
        $id = $record->get($localFieldName);

        if (is_null($id) || ! $this->definition['table']->getAttribute(Doctrine_Core::ATTR_LOAD_REFERENCES)) {
            $related = $this->getTable()->create();

            // Ticket #1131 Patch.
            if ( ! is_null($id)) {
                $related->assignIdentifier($id);
                $related->state(Doctrine_Record::STATE_PROXY);
            }
        } else {
            $dql  = 'FROM ' . $this->getTable()->getComponentName()
                 . ' WHERE ' . $this->getCondition() . $this->getOrderBy(null, false);

            $related = $this->getTable()
                            ->getConnection()
                            ->query($dql, array($id))
                            ->getFirst();

            if ( ! $related || empty($related)) {
                $related = $this->getTable()->create();
            }
        }

        $record->set($localFieldName, $id, false);

        return $related;
    }
开发者ID:nationalfield,项目名称:symfony,代码行数:39,代码来源:LocalKey.php

示例2: _trim

 private function _trim(Doctrine_Record $record)
 {
     foreach ($this->_options['fields'] as $field) {
         if ($record->rawGet($field) != trim($record->rawGet($field))) {
             $record->set($field, trim($record->rawGet($field)), false);
         }
     }
 }
开发者ID:silky,项目名称:littlesis,代码行数:8,代码来源:TrimmableListener.class.php

示例3: set

 public function set($name, $value, $load = true)
 {
     if ($col = $this->getTable()->getColumnDefinition($name)) {
         if ($col["type"] == 'blob') {
             $value = base64_encode($value);
         }
     }
     parent::set($name, $value, $load);
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:9,代码来源:BaseNsmUserPreference.php

示例4: fetchRelatedFor

 /**
  * fetchRelatedFor
  *
  * fetches a component related to given record
  *
  * @param Doctrine_Record $record
  * @return Doctrine_Record|Doctrine_Collection
  */
 public function fetchRelatedFor(Doctrine_Record $record)
 {
     $id = $record->get($this->definition['local']);
     if (empty($id) || !$this->definition['table']->getAttribute(Doctrine::ATTR_LOAD_REFERENCES)) {
         $related = $this->getTable()->create();
     } else {
         $related = $this->getTable()->find($id);
         if (!$related) {
             $related = $this->getTable()->create();
         }
     }
     $record->set($this->definition['local'], $related, false);
     return $related;
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:22,代码来源:LocalKey.php

示例5: fetchRelatedFor

 /**
  * fetchRelatedFor
  *
  * fetches a component related to given record
  *
  * @param Doctrine_Record $record
  * @return Doctrine_Record|Doctrine_Collection
  */
 public function fetchRelatedFor(Doctrine_Record $record)
 {
     $id = $record->get($this->definition['local']);
     if (empty($id) || !$this->definition['table']->getAttribute(Doctrine::ATTR_LOAD_REFERENCES)) {
         $related = $this->getTable()->create();
     } else {
         $dql = 'FROM ' . $this->getTable()->getComponentName() . ' WHERE ' . $this->getCondition();
         $related = $this->getTable()->getConnection()->query($dql, array($id))->getFirst();
         if (!$related || empty($related)) {
             $related = $this->getTable()->create();
         }
     }
     $record->set($this->definition['local'], $related, false);
     return $related;
 }
开发者ID:kirvin,项目名称:the-nerdery,代码行数:23,代码来源:LocalKey.php

示例6: add

 /**
  * Adds a record to collection
  *
  * @param Doctrine_Record $record              record to be added
  * @param string $key                          optional key for the record
  * @return boolean
  */
 public function add($record, $key = null)
 {
     if (isset($this->referenceField)) {
         $value = $this->reference->get($this->relation->getLocalFieldName());
         if ($value !== null) {
             $record->set($this->referenceField, $value, false);
         } else {
             $record->set($this->referenceField, $this->reference, false);
         }
         $relations = $this->relation['table']->getRelations();
         foreach ($relations as $relation) {
             if ($this->relation['class'] == $relation['localTable']->getOption('name') && $relation->getLocal() == $this->relation->getForeignFieldName()) {
                 $record->{$relation}['alias'] = $this->reference;
                 break;
             }
         }
     }
     /**
      * for some weird reason in_array cannot be used here (php bug ?)
      *
      * if used it results in fatal error : [ nesting level too deep ]
      */
     foreach ($this->data as $val) {
         if ($val === $record) {
             return false;
         }
     }
     if (isset($key)) {
         if (isset($this->data[$key])) {
             return false;
         }
         $this->data[$key] = $record;
         return true;
     }
     if (isset($this->keyColumn)) {
         $value = $record->get($this->keyColumn);
         if ($value === null) {
             throw new Doctrine_Collection_Exception("Couldn't create collection index. Record field '" . $this->keyColumn . "' was null.");
         }
         $this->data[$value] = $record;
     } else {
         $this->data[] = $record;
     }
     return true;
 }
开发者ID:stelaireri,项目名称:Hive,代码行数:52,代码来源:Collection.php

示例7: saveRelatedLocalKeys

 /**
  * saveRelatedLocalKeys
  * saves all related (through LocalKey) records to $record
  *
  * @throws PDOException         if something went wrong at database level
  * @param Doctrine_Record $record
  */
 public function saveRelatedLocalKeys(Doctrine_Record $record)
 {
     $state = $record->state();
     $record->state($record->exists() ? Doctrine_Record::STATE_LOCKED : Doctrine_Record::STATE_TLOCKED);
     foreach ($record->getReferences() as $k => $v) {
         $rel = $record->getTable()->getRelation($k);
         $local = $rel->getLocal();
         $foreign = $rel->getForeign();
         if ($rel instanceof Doctrine_Relation_LocalKey) {
             // ONE-TO-ONE relationship
             $obj = $record->get($rel->getAlias());
             // Protection against infinite function recursion before attempting to save
             if ($obj instanceof Doctrine_Record && $obj->isModified()) {
                 $obj->save($this->conn);
                 $id = array_values($obj->identifier());
                 if (!empty($id)) {
                     foreach ((array) $rel->getLocal() as $k => $columnName) {
                         $field = $record->getTable()->getFieldName($columnName);
                         if (isset($id[$k]) && $id[$k] && $record->getTable()->hasField($field)) {
                             $record->set($field, $id[$k]);
                         }
                     }
                 }
             }
         }
     }
     $record->state($state);
 }
开发者ID:sensorsix,项目名称:app,代码行数:35,代码来源:UnitOfWork.php

示例8: set

 public function set($fieldName, $value, $load = true)
 {
     parent::set($fieldName, $value, $load);
 }
开发者ID:dennybrandes,项目名称:doctrine1,代码行数:4,代码来源:638TestCase.php

示例9: saveRelated

 /**
  * saveRelated
  * saves all related records to $record
  *
  * @throws PDOException         if something went wrong at database level
  * @param Doctrine_Record $record
  */
 public function saveRelated(Doctrine_Record $record)
 {
     $saveLater = array();
     foreach ($record->getReferences() as $k => $v) {
         $rel = $record->getTable()->getRelation($k);
         $local = $rel->getLocal();
         $foreign = $rel->getForeign();
         if ($rel instanceof Doctrine_Relation_ForeignKey) {
             $saveLater[$k] = $rel;
         } else {
             if ($rel instanceof Doctrine_Relation_LocalKey) {
                 // ONE-TO-ONE relationship
                 $obj = $record->get($rel->getAlias());
                 // Protection against infinite function recursion before attempting to save
                 if ($obj instanceof Doctrine_Record && $obj->isModified()) {
                     $obj->save($this->conn);
                     $id = array_values($obj->identifier());
                     if (!empty($id)) {
                         foreach ((array) $rel->getLocal() as $k => $field) {
                             if (isset($id[$k]) && $id[$k] && $record->getTable()->hasField($k)) {
                                 $record->set($field, $id[$k]);
                             }
                         }
                     }
                 }
             }
         }
     }
     return $saveLater;
 }
开发者ID:prismhdd,项目名称:victorioussecret,代码行数:37,代码来源:UnitOfWork.php

示例10: add

 /**
  * adds a record to collection
  * @param Doctrine_Record $record              record to be added
  * @param string $key                          optional key for the record
  * @return boolean
  */
 public function add(Doctrine_Record $record, $key = null)
 {
     if (isset($this->referenceField)) {
         $value = $this->reference->get($this->relation->getLocal());
         if ($value !== null) {
             $record->set($this->referenceField, $value, false);
         } else {
             $record->set($this->referenceField, $this->reference, false);
         }
     }
     /**
      * for some weird reason in_array cannot be used here (php bug ?)
      *
      * if used it results in fatal error : [ nesting level too deep ]
      */
     foreach ($this->data as $val) {
         if ($val === $record) {
             return false;
         }
     }
     if (isset($key)) {
         if (isset($this->data[$key])) {
             return false;
         }
         $this->data[$key] = $record;
         return true;
     }
     if (isset($this->keyColumn)) {
         $value = $record->get($this->keyColumn);
         if ($value === null) {
             throw new Doctrine_Collection_Exception("Couldn't create collection index. Record field '" . $this->keyColumn . "' was null.");
         }
         $this->data[$value] = $record;
     } else {
         $this->data[] = $record;
     }
     return true;
 }
开发者ID:kirvin,项目名称:the-nerdery,代码行数:44,代码来源:Collection.php

示例11: rawSet

 /**
  * Use inside of overriden Doctrine accessors
  *
  * @param string $name 
  * @param string $value 
  * @return void
  */
 public function rawSet($name, $value)
 {
     parent::set($name, $value);
 }
开发者ID:amitesh-singh,项目名称:Enlightenment,代码行数:11,代码来源:sfDoctrineRecord.class.php

示例12: copyDoctrineFields

 public static function copyDoctrineFields(Doctrine_Record $a, Doctrine_Record $b, array $fields)
 {
     foreach ($fields as $field) {
         $b->set($field, $a->get($field));
     }
 }
开发者ID:jnankin,项目名称:makeaminyan,代码行数:6,代码来源:Utils.class.php

示例13: refreshPosition

 /**
  * Refreshs the position of the object
  *
  * @param Doctrine_Record $object
  */
 private function refreshPosition(Doctrine_Record $object)
 {
     $identifiers = $object->getTable()->getIdentifierColumnNames();
     $query = $object->getTable()->createQuery()->select($this->_options['name']);
     foreach ($identifiers as $identifier) {
         $query->andWhere($identifier . ' = ?', $object->get($identifier));
     }
     $position = $query->fetchOne(array(), Doctrine::HYDRATE_ARRAY);
     $object->set($this->_options['name'], $position['position'], false);
 }
开发者ID:robo47,项目名称:csDoctrineActAsSortablePlugin-1,代码行数:15,代码来源:Sortable.php

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

示例15: rawSet

 function rawSet($name, $value, $load = true)
 {
     return parent::set($name, $value, $load);
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:4,代码来源:sfDoctrineRecord.class.php


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