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


PHP Doctrine_Record::identifier方法代码示例

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


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

示例1: getRecordAsString

 /**
  * Dumps a record.
  *
  * This method returns an html representation of a given
  * record, containing keys, state and data.
  *
  * @param Doctrine_Record $record
  * @return string
  */
 public static function getRecordAsString(Doctrine_Record $record)
 {
     $r[] = '<pre>';
     $r[] = 'Component  : ' . $record->getTable()->getComponentName();
     $r[] = 'ID         : ' . Doctrine::dump($record->identifier());
     $r[] = 'References : ' . count($record->getReferences());
     $r[] = 'State      : ' . Doctrine_Lib::getRecordStateAsString($record->state());
     $r[] = 'OID        : ' . $record->getOID();
     $r[] = 'data       : ' . Doctrine::dump($record->getData(), false);
     $r[] = '</pre>';
     return implode("\n", $r) . "<br />";
 }
开发者ID:stelaireri,项目名称:Hive,代码行数:21,代码来源:Lib.php

示例2: removeRecord

 /**
  * removeRecord
  * removes a record from the identity map, returning true if the record
  * was found and removed and false if the record wasn't found.
  *
  * @param Doctrine_Record $record       record to be removed
  * @return boolean
  */
 public function removeRecord(Doctrine_Record $record)
 {
     $id = implode(' ', $record->identifier());
     if (isset($this->_identityMap[$id])) {
         unset($this->_identityMap[$id]);
         return true;
     }
     return false;
 }
开发者ID:mediasadc,项目名称:alba,代码行数:17,代码来源:Table.php

示例3: _updateCTIRecord

 /**
  * Class Table Inheritance code.
  * Support dropped for 0.10/1.0.
  */
 private function _updateCTIRecord(Doctrine_Table $table, Doctrine_Record $record)
 {
     $identifier = $record->identifier();
     $dataSet = $this->_formatDataSet($record);
     $component = $table->getComponentName();
     $classes = $table->getOption('joinedParents');
     $classes[] = $component;
     foreach ($record as $field => $value) {
         if ($value instanceof Doctrine_Record) {
             if (!$value->exists()) {
                 $value->save();
             }
             $record->set($field, $value->getIncremented());
         }
     }
     foreach ($classes as $class) {
         $parentTable = $this->conn->getTable($class);
         if (!array_key_exists($class, $dataSet)) {
             continue;
         }
         $this->conn->update($this->conn->getTable($class), $dataSet[$class], $identifier);
     }
 }
开发者ID:sensorsix,项目名称:app,代码行数:27,代码来源:UnitOfWork.php

示例4: getUniqueSlug

 /**
  * Creates a unique slug for a given Doctrine_Record. This function enforces the uniqueness by 
  * incrementing the values with a postfix if the slug is not unique
  *
  * @param Doctrine_Record $record 
  * @param string $slugFromFields
  * @return string $slug
  */
 public function getUniqueSlug($record, $slugFromFields)
 {
     $name = $record->getTable()->getFieldName($this->_options['name']);
     $proposal = call_user_func_array($this->_options['builder'], array($slugFromFields, $record));
     $slug = $proposal;
     $whereString = 'r.' . $name . ' LIKE ?';
     $whereParams = array($proposal . '%');
     if ($record->exists()) {
         $identifier = $record->identifier();
         $whereString .= ' AND r.' . implode(' != ? AND r.', $record->getTable()->getIdentifierColumnNames()) . ' != ?';
         $whereParams = array_merge($whereParams, array_values($identifier));
     }
     foreach ($this->_options['uniqueBy'] as $uniqueBy) {
         if (is_null($record->{$uniqueBy})) {
             $whereString .= ' AND r.' . $uniqueBy . ' IS NULL';
         } else {
             $whereString .= ' AND r.' . $uniqueBy . ' = ?';
             $whereParams[] = $record->{$uniqueBy};
         }
     }
     // Disable indexby to ensure we get all records
     $originalIndexBy = $record->getTable()->getBoundQueryPart('indexBy');
     $record->getTable()->bindQueryPart('indexBy', null);
     $query = Doctrine_Query::create()->select('r.' . $name)->from(get_class($record) . ' r')->where($whereString, $whereParams)->setHydrationMode(Doctrine::HYDRATE_ARRAY);
     // We need to introspect SoftDelete to check if we are not disabling unique records too
     if ($record->getTable()->hasTemplate('Doctrine_Template_SoftDelete')) {
         $softDelete = $record->getTable()->getTemplate('Doctrine_Template_SoftDelete');
         // we have to consider both situations here
         if ($softDelete->getOption('type') == 'boolean') {
             $conn = $query->getConnection();
             $query->addWhere('(r.' . $softDelete->getOption('name') . ' = ' . $conn->convertBooleans(true) . ' OR r.' . $softDelete->getOption('name') . ' = ' . $conn->convertBooleans(false) . ')');
         } else {
             $query->addWhere('(r.' . $softDelete->getOption('name') . ' IS NOT NULL OR r.' . $softDelete->getOption('name') . ' IS NULL)');
         }
     }
     $similarSlugResult = $query->execute();
     $query->free();
     // Change indexby back
     $record->getTable()->bindQueryPart('indexBy', $originalIndexBy);
     $similarSlugs = array();
     foreach ($similarSlugResult as $key => $value) {
         $similarSlugs[$key] = $value[$name];
     }
     $i = 1;
     while (in_array($slug, $similarSlugs)) {
         $slug = call_user_func_array($this->_options['builder'], array($proposal . '-' . $i, $record));
         $i++;
     }
     // If slug is longer then the column length then we need to trim it
     // and try to generate a unique slug again
     $length = $record->getTable()->getFieldLength($this->_options['name']);
     if (strlen($slug) > $length) {
         $slug = substr($slug, 0, $length - (strlen($i) + 1));
         $slug = $this->getUniqueSlug($record, $slug);
     }
     return $slug;
 }
开发者ID:darkcolonist,项目名称:kohana234-doctrine115,代码行数:65,代码来源:Sluggable.php

示例5: moveAsLastChildOf

 /**
  * moves node as last child of dest record
  *        
  */
 public function moveAsLastChildOf(Doctrine_Record $dest)
 {
     if ($dest === $this->record || $dest->exists() && $this->record->exists() && $dest->identifier() === $this->record->identifier()) {
         throw new Doctrine_Tree_Exception("Cannot move node as last child of itself");
         return false;
     }
     if ($dest->getNode()->getRootValue() != $this->getRootValue()) {
         // Move between trees
         return $this->_moveBetweenTrees($dest, $dest->getNode()->getRightValue(), __FUNCTION__);
     } else {
         // Move within tree
         $oldLevel = $this->record['level'];
         $this->record['level'] = $dest['level'] + 1;
         $this->updateNode($dest->getNode()->getRightValue(), $this->record['level'] - $oldLevel);
     }
     return true;
 }
开发者ID:hasanozgan,项目名称:kissabe,代码行数:21,代码来源:NestedSet.php

示例6: getUniqueSlug

 /**
  * Creates a unique slug for a given Doctrine_Record. This function enforces the uniqueness by 
  * incrementing the values with a postfix if the slug is not unique
  *
  * @param Doctrine_Record $record 
  * @return string $slug
  */
 public function getUniqueSlug($record)
 {
     $name = $record->getTable()->getFieldName($this->_options['name']);
     $slugFromFields = '';
     foreach ($this->_options['fields'] as $field) {
         $slugFromFields .= $record->{$field} . ' ';
     }
     $proposal = $record->{$name} ? $record->{$name} : $slugFromFields;
     $proposal = call_user_func_array($this->_options['builder'], array($proposal, $record));
     $slug = $proposal;
     $whereString = 'r.' . $name . ' LIKE ?';
     $whereParams = array($proposal . '%');
     if ($record->exists()) {
         $identifier = $record->identifier();
         $whereString .= ' AND r.' . implode(' != ? AND r.', $record->getTable()->getIdentifierColumnNames()) . ' != ?';
         $whereParams = array_merge($whereParams, array_values($identifier));
     }
     foreach ($this->_options['uniqueBy'] as $uniqueBy) {
         if (is_null($record->{$uniqueBy})) {
             $whereString .= ' AND r.' . $uniqueBy . ' IS NULL';
         } else {
             $whereString .= ' AND r.' . $uniqueBy . ' = ?';
             $whereParams[] = $record->{$uniqueBy};
         }
     }
     // Disable indexby to ensure we get all records
     $originalIndexBy = $record->getTable()->getBoundQueryPart('indexBy');
     $record->getTable()->bindQueryPart('indexBy', null);
     $query = Doctrine_Query::create()->select('r.' . $name)->from(get_class($record) . ' r')->where($whereString, $whereParams)->setHydrationMode(Doctrine::HYDRATE_ARRAY);
     // We need to introspect SoftDelete to check if we are not disabling unique records too
     if ($record->getTable()->hasTemplate('Doctrine_Template_SoftDelete')) {
         $softDelete = $record->getTable()->getTemplate('Doctrine_Template_SoftDelete');
         // we have to consider both situations here
         $query->addWhere('(r.' . $softDelete->getOption('name') . ' = true OR r.' . $softDelete->getOption('name') . ' IS NOT NULL OR r.' . $softDelete->getOption('name') . ' = false OR r.' . $softDelete->getOption('name') . ' IS NULL)');
     }
     $similarSlugResult = $query->execute();
     // Change indexby back
     $record->getTable()->bindQueryPart('indexBy', $originalIndexBy);
     $similarSlugs = array();
     foreach ($similarSlugResult as $key => $value) {
         $similarSlugs[$key] = $value[$name];
     }
     $i = 1;
     while (in_array($slug, $similarSlugs)) {
         $slug = call_user_func_array($this->_options['builder'], array($proposal . '-' . $i, $record));
         $i++;
     }
     return $slug;
 }
开发者ID:googlecode-mirror,项目名称:orso,代码行数:56,代码来源:Sluggable.php

示例7: getUniqueSlug

 /**
  * getUniqueSlug
  *
  * Creates a unique slug for a given Doctrine_Record. This function enforces the uniqueness by incrementing
  * the values with a postfix if the slug is not unique
  *
  * @param Doctrine_Record $record 
  * @return string $slug
  */
 public function getUniqueSlug($record)
 {
     $name = $this->_options['name'];
     $slugFromFields = '';
     foreach ($this->_options['fields'] as $field) {
         $slugFromFields .= $record->{$field} . ' ';
     }
     $proposal = $record->{$name} ? $record->{$name} : $slugFromFields;
     $proposal = Doctrine_Inflector::urlize($proposal);
     $slug = $proposal;
     $whereString = 'r.' . $name . ' LIKE ?';
     $whereParams = array($proposal . '%');
     if ($record->exists()) {
         $identifier = $record->identifier();
         $whereString .= ' AND r.' . implode(' != ? AND r.', $record->getTable()->getIdentifierColumnNames()) . ' != ?';
         $whereParams = array_merge($whereParams, array_values($identifier));
     }
     foreach ($this->_options['uniqueBy'] as $uniqueBy) {
         if (is_null($record->{$uniqueBy})) {
             $whereString .= ' AND r.' . $uniqueBy . ' IS NULL';
         } else {
             $whereString .= ' AND r.' . $uniqueBy . ' = ?';
             $whereParams[] = $record->{$uniqueBy};
         }
     }
     $query = Doctrine_Query::create()->select('r.' . $name)->from(get_class($record) . ' r')->where($whereString, $whereParams)->setHydrationMode(Doctrine::HYDRATE_ARRAY);
     $similarSlugResult = $query->execute();
     $similarSlugs = array();
     foreach ($similarSlugResult as $key => $value) {
         $similarSlugs[$key] = $value[$name];
     }
     $i = 1;
     while (in_array($slug, $similarSlugs)) {
         $slug = $proposal . '-' . $i;
         $i++;
     }
     return $slug;
 }
开发者ID:walterfrs,项目名称:mladek,代码行数:47,代码来源:Sluggable.php

示例8: getSingleColumnListenerId

 /**
  * Returns a unique ID for the given listener. So, we have no problems with 
  * composite primary keys.
  * 
  * @return string
  */
 public static final function getSingleColumnListenerId(Doctrine_Record $listener)
 {
     $id = (array) $listener->identifier();
     if (count($id) > 1) {
         return serialize($id);
     }
     return strval(reset($id));
 }
开发者ID:schmittjoh,项目名称:jmsPaymentPlugin,代码行数:14,代码来源:PluginPaymentListener.class.php

示例9: addRecord

 /**
  * addRecord
  * adds a record to identity map
  *
  * @param Doctrine_Record $record       record to be added
  * @return boolean
  */
 public function addRecord(Doctrine_Record $record)
 {
     $id = implode(' ', $record->identifier());
     if (isset($this->identityMap[$id])) {
         return false;
     }
     $this->identityMap[$id] = $record;
     return true;
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:16,代码来源:Table.php

示例10: restrictRecordFromQuery

 /**
  * make sure the given record is NOT returned by the query by adding its ID value(s) to the WHERE clause (where id != {this_id} or similar)
  * NOTE: the query needs to be querying the same table as the record
  * @param $query
  * @param $record
  * @return null
  */
 private function restrictRecordFromQuery(Doctrine_Query &$query, Doctrine_Record &$record)
 {
     // restrict query to not return the row that we're working on. This prevents updates from triggering unnecessary nesting
     $id = $record->identifier();
     if (!$id) {
         return;
     }
     $where_text = '(' . implode(' != ? OR ', array_keys($id)) . ' != ?)';
     $query->addWhere($where_text, array_values($id));
 }
开发者ID:JoshuaEstes,项目名称:sfDoctrineExtraPlugin,代码行数:17,代码来源:Temporal.php

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

示例12: update

 /**
  * updates 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($record, Doctrine_Event::RECORD_UPDATE);
     $record->preUpdate($event);
     $table = $record->getTable();
     $table->getRecordListener()->preUpdate($event);
     if (!$event->skipOperation) {
         $identifier = $record->identifier();
         if ($table->getOption('joinedParents')) {
             $dataSet = $this->formatDataSet($record);
             $component = $table->getComponentName();
             $classes = $table->getOption('joinedParents');
             $classes[] = $component;
             foreach ($record as $field => $value) {
                 if ($value instanceof Doctrine_Record) {
                     if (!$value->exists()) {
                         $value->save();
                     }
                     $record->set($field, $value->getIncremented());
                 }
             }
             foreach ($classes as $class) {
                 $parentTable = $this->conn->getTable($class);
                 $this->conn->update($this->conn->getTable($class), $dataSet[$class], $identifier);
             }
         } else {
             $array = $record->getPrepared();
             $this->conn->update($table, $array, $identifier);
         }
         $record->assignIdentifier(true);
     }
     $table->getRecordListener()->postUpdate($event);
     $record->postUpdate($event);
     return true;
 }
开发者ID:kirvin,项目名称:the-nerdery,代码行数:41,代码来源:UnitOfWork.php


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