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


PHP Doctrine_Record::exists方法代码示例

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


在下文中一共展示了Doctrine_Record::exists方法的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)
 {
     $id = array();
     $localTable = $record->getTable();
     foreach ((array) $this->definition['local'] as $local) {
         $value = $record->get($localTable->getFieldName($local));
         if (isset($value)) {
             $id[] = $value;
         }
     }
     if ($this->isOneToOne()) {
         if (!$record->exists() || empty($id) || !$this->definition['table']->getAttribute(Doctrine::ATTR_LOAD_REFERENCES)) {
             $related = $this->getTable()->create();
         } else {
             $dql = 'FROM ' . $this->getTable()->getComponentName() . ' WHERE ' . $this->getCondition();
             $coll = $this->getTable()->getConnection()->query($dql, $id);
             $related = $coll[0];
         }
         $related->set($related->getTable()->getFieldName($this->definition['foreign']), $record, false);
     } else {
         if (!$record->exists() || empty($id) || !$this->definition['table']->getAttribute(Doctrine::ATTR_LOAD_REFERENCES)) {
             $related = Doctrine_Collection::create($this->getTable());
         } else {
             $query = $this->getRelationDql(1);
             $related = $this->getTable()->getConnection()->query($query, $id);
         }
         $related->setReference($record, $this);
     }
     return $related;
 }
开发者ID:swk,项目名称:bluebox,代码行数:38,代码来源:ForeignKey.php

示例2: setObject

 public function setObject(Doctrine_Record $record)
 {
     if (!$record->exists()) {
         throw new Exception("Can't set ObjectTag's object to new object");
     }
     $this->object_model = get_class($record);
     $this->object_id = $record->id;
 }
开发者ID:silky,项目名称:littlesis,代码行数:8,代码来源:ObjectTag.class.php

示例3: getByModelAndObjectQuery

 static function getByModelAndObjectQuery($model, Doctrine_Record $object)
 {
     if (!$object->exists()) {
         throw new Exception("Can't get " . LsString::pluralize($model) . " by new object");
     }
     $alias = substr(strtolower($model), 0, 1);
     return LsDoctrineQuery::create()->from($model . ' ' . $alias)->where($alias . '.object_model = ? AND ' . $alias . '.object_id = ?', array(get_class($object), $object->id));
 }
开发者ID:silky,项目名称:littlesis,代码行数:8,代码来源:Objectable.class.php

示例4: validateRecord

 /**
  * Validates a given record and saves possible errors in Doctrine_Validator::$stack
  *
  * @param  Doctrine_Record $record
  * @return void
  */
 public function validateRecord(Doctrine_Record $record)
 {
     $table = $record->getTable();
     // if record is transient all fields will be validated
     // if record is persistent only the modified fields will be validated
     $fields = $record->exists() ? $record->getModified() : $record->getData();
     foreach ($fields as $fieldName => $value) {
         $table->validateField($fieldName, $value, $record);
     }
 }
开发者ID:googlecode-mirror,项目名称:orso,代码行数:16,代码来源:Validator.php

示例5: _form

 protected function _form(Doctrine_Record $entity)
 {
     $form = $this->_getForm();
     if ($entity->exists()) {
         $form->setDefaults($entity->toArray());
     }
     if ($this->getRequest()->getParam('cancel')) {
         $this->_redirectToIndex();
     }
     if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getParams())) {
         $messageKey = 'entityAdded';
         if ($entity->exists()) {
             $messageKey = 'entityUpdated';
         }
         $this->_saveEntity($entity, $form);
         $this->_helper->messenger->success($this->_messages[$messageKey]);
         $this->_redirectToIndex();
     }
     $this->view->form = $form;
 }
开发者ID:prosalov,项目名称:zf1-code-example,代码行数:20,代码来源:Crud.php

示例6: createRoot

 /**
  * Creates root node from given record or from a new record.
  *
  * Note: When using a tree with multiple root nodes (hasManyRoots), you MUST pass in a
  * record to use as the root. This can either be a new/transient record that already has
  * the root id column set to some numeric value OR a persistent record. In the latter case
  * the records id will be assigned to the root id. You must use numeric columns for the id
  * and root id columns.
  *
  * @param object $record        instance of Doctrine_Record
  */
 public function createRoot(Doctrine_Record $record = null)
 {
     if ($this->getAttribute('hasManyRoots')) {
         if (!$record || !$record->exists() && $record->getNode()->getRootValue() <= 0 || $record->getTable()->isIdentifierComposite()) {
             throw new Doctrine_Tree_Exception("Node must have a root id set or must " . " be persistent and have a single-valued numeric primary key in order to" . " be created as a root node. Automatic assignment of a root id on" . " transient/new records is no longer supported.");
         }
         if ($record->exists() && $record->getNode()->getRootValue() <= 0) {
             // Default: root_id = id
             $identifier = $record->getTable()->getIdentifier();
             $record->getNode()->setRootValue($record->get($identifier));
         }
     }
     if (!$record) {
         $record = $this->table->create();
     }
     $record->set('lft', '1');
     $record->set('rgt', '2');
     $record->set('level', 0);
     $record->save();
     return $record;
 }
开发者ID:JimmyVB,项目名称:Symfony-v1.2,代码行数:32,代码来源:NestedSet.php

示例7: mergeFrom

 public function mergeFrom(Doctrine_Record $r)
 {
     $object = $this->getInvoker();
     if (!$r->exists() || !$object->exists()) {
         foreach ($r->getUserFavoritesQuery()->execute() as $favorite) {
             $q = LsDoctrineQuery::create()->from('UserFavorite uf')->where('uf.object_model = ? AND uf.object_id AND uf.user_id = ?', array(get_class($object), $object->id, $favorite->user_id));
             if (!$q->count()) {
                 $favorite->setObject($object);
                 $favorite->save();
             }
         }
     }
 }
开发者ID:silky,项目名称:littlesis,代码行数:13,代码来源:Favoriteable.class.php

示例8: logView

 static function logView(Doctrine_Record $record)
 {
     $user = sfContext::getInstance()->getUser();
     if (!sfConfig::get('app_logging_views') || !$user->isAuthenticated()) {
         return;
     }
     if (!$record->exists()) {
         throw new Exception("Can't log user view for new record");
     }
     $view = new UserView();
     $view->setObject($record);
     $view->User = $user->getGuardUser();
     $view->save();
 }
开发者ID:silky,项目名称:littlesis,代码行数:14,代码来源:UserViewTable.class.php

示例9: filterGet

 /**
  * filterGet
  * defines an implementation for filtering the get() method of Doctrine_Record
  *
  * @param mixed $name                       name of the property or related component
  */
 public function filterGet(Doctrine_Record $record, $name)
 {
     foreach ($this->_aliases as $alias) {
         if (!$record->exists()) {
             if (isset($record[$alias][$name])) {
                 return $record[$alias][$name];
             }
         } else {
             if (isset($record[$alias][$name])) {
                 return $record[$alias][$name];
             }
         }
     }
 }
开发者ID:broschb,项目名称:cyclebrain,代码行数:20,代码来源:Compound.php

示例10: filterGet

 /**
  * filterGet
  * defines an implementation for filtering the get() method of Doctrine_Record
  *
  * @param mixed $name                       name of the property or related component
  */
 public function filterGet(Doctrine_Record $record, $name)
 {
     foreach ($this->_aliases as $alias) {
         if (!$record->exists()) {
             if (isset($record[$alias][$name])) {
                 return $record[$alias][$name];
             }
         } else {
             if (isset($record[$alias][$name])) {
                 return $record[$alias][$name];
             }
         }
     }
     throw new Doctrine_Record_UnknownPropertyException(sprintf('Unknown record property / related component "%s" on "%s"', $name, get_class($record)));
 }
开发者ID:sensorsix,项目名称:app,代码行数:21,代码来源:Compound.php

示例11: filterGet

 /**
  * filterGet
  * defines an implementation for filtering the get() method of Doctrine_Record
  *
  * @param mixed $name                       name of the property or related component
  */
 public function filterGet(Doctrine_Record $record, $name)
 {
     foreach ($this->_aliases as $alias) {
         if (!$record->exists()) {
             if (isset($record[$alias][$name])) {
                 return $record[$alias][$name];
             }
         } else {
             // we do not want to execute N + 1 queries here, hence we cannot use get()
             if (($ref = $record->reference($alias)) !== null) {
                 if (isset($ref[$name])) {
                     return $ref[$name];
                 }
             }
         }
     }
 }
开发者ID:prismhdd,项目名称:victorioussecret,代码行数:23,代码来源:Compound.php

示例12: mergeFrom

 public function mergeFrom(Doctrine_Record $r)
 {
     $object = $this->getInvoker();
     if (!$r->exists() || !$object->exists()) {
         return false;
     }
     foreach ($r->getReferencesByFields() as $ref) {
         if (count($ref->Excerpt)) {
             foreach ($ref->Excerpt as $excerpt) {
                 $object->addReference($ref->source, $excerpt->body, $ref->getFieldsArray(), $ref->name, $ref->source_detail, $ref->publication_date);
             }
         } else {
             $object->addReference($ref->source, null, $ref->getFieldsArray(), $ref->name, $ref->source_detail, $ref->publication_date);
         }
         $ref->delete();
     }
     return true;
 }
开发者ID:silky,项目名称:littlesis,代码行数:18,代码来源:Referenceable.class.php

示例13: mergeFrom

 public function mergeFrom(Doctrine_Record $r)
 {
     $object = $this->getInvoker();
     if (!$r->exists() || !$object->exists()) {
         return false;
     }
     foreach ($r->getObjectTagsQuery()->execute() as $objectTag) {
         $q = LsQuery::getByModelAndFieldsQuery('ObjectTag', array('object_model' => get_class($object), 'object_id' => $object->id, 'tag_id' => $objectTag->tag_id));
         if (!$q->count()) {
             $objectTag->object_model = get_class($object);
             $objectTag->object_id = $object->id;
             $objectTag->save();
         } else {
             $objectTag->delete();
         }
     }
     return true;
 }
开发者ID:silky,项目名称:littlesis,代码行数:18,代码来源:Taggable.class.php

示例14: collect

 /**
  * @see Doctrine_Connection_UnitOfWork::_collectDeletions() copy&past from
  *
  * @param Doctrine_Record $record
  * @param array $definitions
  * @return null
  */
 private function collect(Doctrine_Record $record, &$definitions)
 {
     if (!$record->exists()) {
         return;
     }
     if (!$record->getTable()->hasTemplate(sfCacheTaggingToolkit::TEMPLATE_NAME)) {
         return;
     }
     # delete definitions
     if ($this->tagNamesToDelete === $definitions) {
         $definitions[$record->getOid()] = $record->obtainTagName();
         $this->cascade($record);
     } else {
         # do not call cascade - due to SET NULL only updates columns
         # do not add tag, if its already on deletion list
         if (!array_key_exists($record->getOid(), $this->tagNamesToDelete)) {
             $definitions[$record->getOid()] = $record->obtainTagName();
         }
     }
 }
开发者ID:uniteddiversity,项目名称:policat,代码行数:27,代码来源:CachetaggableUnitOfWork.php

示例15: mergeFrom

 public function mergeFrom(Doctrine_Record $r)
 {
     $object = $this->getInvoker();
     if (!$r->exists() || !$object->exists()) {
         return false;
     }
     //create delete record for merged entity
     LsVersionableListener::logDelete($r, $object['id']);
     return true;
 }
开发者ID:silky,项目名称:littlesis,代码行数:10,代码来源:LsVersionable.class.php


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