當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。