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


PHP Doctrine_Record::getIncremented方法代码示例

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


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

示例1: fetchRelatedFor

    public function fetchRelatedFor(Doctrine_Record $record)
    {
        $id      = $record->getIncremented();

        $q = new Doctrine_RawSql();

        $assocTable = $this->getAssociationFactory()->getTableName();
        $tableName  = $record->getTable()->getTableName();
        $identifierColumnNames = $record->getTable()->getIdentifierColumnNames();
        $identifier = array_pop($identifierColumnNames);

        $sub     = 'SELECT '.$this->getForeign().
                   ' FROM '.$assocTable.
                   ' WHERE '.$this->getLocal().
                   ' = ?';

        $sub2   = 'SELECT '.$this->getLocal().
                  ' FROM '.$assocTable.
                  ' WHERE '.$this->getForeign().
                  ' = ?';

        $q->select('{'.$tableName.'.*}, {'.$assocTable.'.*}')
          ->from($tableName . ' INNER JOIN '.$assocTable.' ON '.
                 $tableName . '.' . $identifier . ' = ' . $assocTable . '.' . $this->getLocal() . ' OR ' .
                 $tableName . '.' . $identifier . ' = ' . $assocTable . '.' . $this->getForeign()
                 )
          ->where($tableName.'.'.$identifier.' IN ('.$sub.') OR '.
                  $tableName.'.'.$identifier.' IN ('.$sub2.')'
                );
        $q->addComponent($tableName,  $record->getTable()->getComponentName());
        $q->addComponent($assocTable, $record->getTable()->getComponentName(). '.' . $this->getAssociationFactory()->getComponentName());
        $q->orderBy($this->getOrderByStatement($tableName, true));

        return $q->execute(array($id, $id));
    }
开发者ID:nationalfield,项目名称:symfony,代码行数:35,代码来源:Self.php

示例2: fetchRelatedFor

 public function fetchRelatedFor(Doctrine_Record $record)
 {
     $id = $record->getIncremented();
     if (empty($id) || !$this->definition['table']->getAttribute(Doctrine_Core::ATTR_LOAD_REFERENCES)) {
         return Doctrine_Collection::create($this->getTable());
     } else {
         $q = new Doctrine_RawSql($this->getTable()->getConnection());
         $assocTable = $this->getAssociationFactory()->getTableName();
         $tableName = $record->getTable()->getTableName();
         $identifierColumnNames = $record->getTable()->getIdentifierColumnNames();
         $identifier = array_pop($identifierColumnNames);
         $sub = 'SELECT ' . $this->getForeignRefColumnName() . ' FROM ' . $assocTable . ' WHERE ' . $this->getLocalRefColumnName() . ' = ?';
         $condition[] = $tableName . '.' . $identifier . ' IN (' . $sub . ')';
         $joinCondition[] = $tableName . '.' . $identifier . ' = ' . $assocTable . '.' . $this->getForeignRefColumnName();
         if ($this->definition['equal']) {
             $sub2 = 'SELECT ' . $this->getLocalRefColumnName() . ' FROM ' . $assocTable . ' WHERE ' . $this->getForeignRefColumnName() . ' = ?';
             $condition[] = $tableName . '.' . $identifier . ' IN (' . $sub2 . ')';
             $joinCondition[] = $tableName . '.' . $identifier . ' = ' . $assocTable . '.' . $this->getLocalRefColumnName();
         }
         $q->select('{' . $tableName . '.*}, {' . $assocTable . '.*}')->from($tableName . ' INNER JOIN ' . $assocTable . ' ON ' . implode(' OR ', $joinCondition))->where(implode(' OR ', $condition))->orderBy($tableName . '.' . $identifier . ' ASC');
         if ($orderBy = $this->getOrderByStatement($tableName, true)) {
             $q->addOrderBy($orderBy);
         }
         $q->addComponent($tableName, $this->getClass());
         $path = $this->getClass() . '.' . $this->getAssociationFactory()->getComponentName();
         if ($this->definition['refClassRelationAlias']) {
             $path = $this->getClass() . '.' . $this->definition['refClassRelationAlias'];
         }
         $q->addComponent($assocTable, $path);
         $params = $this->definition['equal'] ? array($id, $id) : array($id);
         $res = $q->execute($params);
         return $res;
     }
 }
开发者ID:tests1,项目名称:zendcasts,代码行数:34,代码来源:Nest.php

示例3: fetchRelatedFor

 /**
 public function fetchRelatedFor(Doctrine_Record $record)
 {
     $id = $record->getIncremented();
 
     if (empty($id) || ! $this->definition['table']->getAttribute(Doctrine::ATTR_LOAD_REFERENCES)) {
         return new Doctrine_Collection($this->getTable());
     } else {
         $q = new Doctrine_Query();
         
         $c  = $this->getTable()->getComponentName();
         $a  = substr($c, 0, 1);
         $c2 = $this->getAssociationTable()->getComponentName();
         $a2 = substr($c2, 0, 1);
 
         $q->from($c)
           ->innerJoin($c . '.' . $c2)
 
         $sub = 'SELECT ' . $this->getForeign() 
              . ' FROM '  . $c2
              . ' WHERE ' . $this->getLocal() 
              . ' = ?';
     }
 }
 */
 public function fetchRelatedFor(Doctrine_Record $record)
 {
     $id = $record->getIncremented();
     if (empty($id) || !$this->definition['table']->getAttribute(Doctrine::ATTR_LOAD_REFERENCES)) {
         return new Doctrine_Collection($this->getTable());
     } else {
         $q = new Doctrine_RawSql();
         $assocTable = $this->getAssociationFactory()->getTableName();
         $tableName = $record->getTable()->getTableName();
         $identifier = $record->getTable()->getIdentifier();
         $sub = 'SELECT ' . $this->getForeign() . ' FROM ' . $assocTable . ' WHERE ' . $this->getLocal() . ' = ?';
         $condition[] = $tableName . '.' . $identifier . ' IN (' . $sub . ')';
         $joinCondition[] = $tableName . '.' . $identifier . ' = ' . $assocTable . '.' . $this->getForeign();
         if ($this->definition['equal']) {
             $sub2 = 'SELECT ' . $this->getLocal() . ' FROM ' . $assocTable . ' WHERE ' . $this->getForeign() . ' = ?';
             $condition[] = $tableName . '.' . $identifier . ' IN (' . $sub2 . ')';
             $joinCondition[] = $tableName . '.' . $identifier . ' = ' . $assocTable . '.' . $this->getLocal();
         }
         $q->select('{' . $tableName . '.*}, {' . $assocTable . '.*}')->from($tableName . ' INNER JOIN ' . $assocTable . ' ON ' . implode(' OR ', $joinCondition))->where(implode(' OR ', $condition));
         $q->addComponent($tableName, $record->getTable()->getComponentName());
         $q->addComponent($assocTable, $record->getTable()->getComponentName() . '.' . $this->getAssociationFactory()->getComponentName());
         $params = $this->definition['equal'] ? array($id, $id) : array($id);
         return $q->execute($params);
     }
 }
开发者ID:kirvin,项目名称:the-nerdery,代码行数:50,代码来源:Nest.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->getIncremented();
     if (empty($id) || !$this->definition['table']->getAttribute(Doctrine::ATTR_LOAD_REFERENCES)) {
         $coll = new Doctrine_Collection($this->getTable());
     } else {
         $coll = Doctrine_Query::create()->parseQuery($this->getRelationDql(1))->execute(array($id));
     }
     return $coll;
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:18,代码来源:Association.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->getIncremented();
     if (empty($id) || !$this->definition['table']->getAttribute(Doctrine::ATTR_LOAD_REFERENCES)) {
         $coll = new Doctrine_Collection($this->getTable());
     } else {
         $coll = $this->getTable()->getConnection()->query($this->getRelationDql(1), array($id));
     }
     $coll->setReference($record, $this);
     return $coll;
 }
开发者ID:prismhdd,项目名称:victorioussecret,代码行数:19,代码来源:Association.php

示例6: saveAssociations

 /**
  * saveAssociations
  *
  * this method takes a diff of one-to-many / many-to-many original and
  * current collections and applies the changes
  *
  * for example if original many-to-many related collection has records with
  * primary keys 1,2 and 3 and the new collection has records with primary keys
  * 3, 4 and 5, this method would first destroy the associations to 1 and 2 and then
  * save new associations to 4 and 5
  *
  * @throws Doctrine_Connection_Exception         if something went wrong at database level
  * @param Doctrine_Record $record
  * @return void
  */
 public function saveAssociations(Doctrine_Record $record)
 {
     foreach ($record->getReferences() as $k => $v) {
         $rel = $record->getTable()->getRelation($k);
         if ($rel instanceof Doctrine_Relation_Association) {
             if ($this->conn->getAttribute(Doctrine_Core::ATTR_CASCADE_SAVES) || $v->isModified()) {
                 $v->save($this->conn, false);
             }
             $assocTable = $rel->getAssociationTable();
             foreach ($v->getDeleteDiff() as $r) {
                 $query = 'DELETE FROM ' . $assocTable->getTableName() . ' WHERE ' . $rel->getForeignRefColumnName() . ' = ?' . ' AND ' . $rel->getLocalRefColumnName() . ' = ?';
                 $this->conn->execute($query, array($r->getIncremented(), $record->getIncremented()));
             }
             foreach ($v->getInsertDiff() as $r) {
                 $assocRecord = $assocTable->create();
                 $assocRecord->set($assocTable->getFieldName($rel->getForeign()), $r);
                 $assocRecord->set($assocTable->getFieldName($rel->getLocal()), $record);
                 $this->saveGraph($assocRecord);
             }
             // take snapshot of collection state, so that we know when its modified again
             $v->takeSnapshot();
         }
     }
 }
开发者ID:sensorsix,项目名称:app,代码行数:39,代码来源:UnitOfWork.php

示例7: saveAssociations

 /**
  * saveAssociations
  *
  * this method takes a diff of one-to-many / many-to-many original and
  * current collections and applies the changes
  *
  * for example if original many-to-many related collection has records with
  * primary keys 1,2 and 3 and the new collection has records with primary keys
  * 3, 4 and 5, this method would first destroy the associations to 1 and 2 and then
  * save new associations to 4 and 5
  *
  * @throws PDOException         if something went wrong at database level
  * @param Doctrine_Record $record
  * @return void
  */
 public function saveAssociations(Doctrine_Record $record)
 {
     foreach ($record->getReferences() as $k => $v) {
         $rel = $record->getTable()->getRelation($k);
         if ($rel instanceof Doctrine_Relation_Association) {
             $v->save($this->conn);
             $assocTable = $rel->getAssociationTable();
             foreach ($v->getDeleteDiff() as $r) {
                 $query = 'DELETE FROM ' . $assocTable->getTableName() . ' WHERE ' . $rel->getForeign() . ' = ?' . ' AND ' . $rel->getLocal() . ' = ?';
                 $this->conn->execute($query, array($r->getIncremented(), $record->getIncremented()));
             }
             foreach ($v->getInsertDiff() as $r) {
                 $assocRecord = $assocTable->create();
                 $assocRecord->set($rel->getForeign(), $r);
                 $assocRecord->set($rel->getLocal(), $record);
                 $assocRecord->save($this->conn);
             }
         }
     }
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:35,代码来源:UnitOfWork.php

示例8: 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 = -1;
     try {
         $recId = $record->get($this->getLocalRefFieldName());
         if ($recId) {
             $id = $recId;
         } else {
             $id = $record->getIncremented();
         }
     } catch (Exception $e) {
         $id = $record->getIncremented();
     }
     $this->tmp_rec = $record;
     if (empty($id) || !$this->definition['table']->getAttribute(Doctrine_Core::ATTR_LOAD_REFERENCES)) {
         $coll = Doctrine_Collection::create($this->getTable());
     } else {
         $coll = $this->getTable()->getConnection()->query($this->getRelationDql(1), array($id));
     }
     $coll->setReference($record, $this);
     return $coll;
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:30,代码来源:Association.php


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