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


PHP Author::isModified方法代码示例

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


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

示例1: doSave

 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param PropelPDO $con
  * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their corresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aAuthor !== null) {
             if ($this->aAuthor->isModified() || $this->aAuthor->isNew()) {
                 $affectedRows += $this->aAuthor->save($con);
             }
             $this->setAuthor($this->aAuthor);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:41,代码来源:BaseBook.php

示例2: doSave

 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aAuthor !== null) {
             if ($this->aAuthor->isModified() || $this->aAuthor->isNew()) {
                 $affectedRows += $this->aAuthor->save($con);
             }
             $this->setAuthor($this->aAuthor);
         }
         if ($this->aArticle !== null) {
             if ($this->aArticle->isModified() || $this->aArticle->isNew()) {
                 $affectedRows += $this->aArticle->save($con);
             }
             $this->setArticle($this->aArticle);
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = AuthorArticlePeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setNew(false);
             } else {
                 $affectedRows += AuthorArticlePeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
开发者ID:yaonicky,项目名称:mac-config,代码行数:52,代码来源:BaseAuthorArticle.php

示例3: doSave

 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aAuthor !== null) {
             if ($this->aAuthor->isModified() || $this->aAuthor->isNew()) {
                 $affectedRows += $this->aAuthor->save($con);
             }
             $this->setAuthor($this->aAuthor);
         }
         if ($this->isNew()) {
             $this->modifiedColumns[] = BookPeer::ID;
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $criteria = $this->buildCriteria();
                 if ($criteria->keyContainsValue(BookPeer::ID)) {
                     throw new PropelException('Cannot insert a value for auto-increment primary key (' . BookPeer::ID . ')');
                 }
                 $pk = BasePeer::doInsert($criteria, $con);
                 $affectedRows += 1;
                 $this->setId($pk);
                 //[IMV] update autoincrement primary key
                 $this->setNew(false);
             } else {
                 $affectedRows += BookPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:52,代码来源:BaseBook.php

示例4: testIsModifiedAndNullValues

 public function testIsModifiedAndNullValues()
 {
     $a = new Author();
     $a->setFirstName('');
     $a->setLastName('Bar');
     $a->setAge(0);
     $a->save();
     $a->setFirstName(null);
     $this->assertTrue($a->isModified(), "Expected Author to be modified after changing empty string column value to NULL.");
     $a->setAge(null);
     $this->assertTrue($a->isModified(), "Expected Author to be modified after changing 0-value int column to NULL.");
     $a->setFirstName('');
     $this->assertTrue($a->isModified(), "Expected Author to be modified after changing NULL column value to empty string.");
     $a->setAge(0);
     $this->assertTrue($a->isModified(), "Expected Author to be modified after changing NULL column to 0-value int.");
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:16,代码来源:GeneratedObjectTest.php

示例5: testIsModified

 /**
  * Test for correct reporting of isModified().
  */
 public function testIsModified()
 {
     // 1) Basic test
     $a = new Author();
     $a->setFirstName("John");
     $a->setLastName("Doe");
     $a->setAge(25);
     $this->assertTrue($a->isModified(), "Expected Author to be modified after setting values.");
     $a->save();
     $this->assertFalse($a->isModified(), "Expected Author to be unmodified after saving set values.");
     // 2) Test behavior with setting vars of different types
     // checking setting int col to string val
     $a->setAge('25');
     $this->assertFalse($a->isModified(), "Expected Author to be unmodified after setting int column to string-cast of same value.");
     $a->setFirstName("John2");
     $this->assertTrue($a->isModified(), "Expected Author to be modified after changing string column value.");
     // checking setting string col to int val
     $a->setFirstName("1");
     $a->save();
     $this->assertFalse($a->isModified(), "Expected Author to be unmodified after saving set values.");
     $a->setFirstName(1);
     $this->assertFalse($a->isModified(), "Expected Author to be unmodified after setting string column to int-cast of same value.");
     // 3) Test for appropriate behavior of NULL
     // checking "" -> NULL
     $a->setFirstName("");
     $a->save();
     $this->assertFalse($a->isModified(), "Expected Author to be unmodified after saving set values.");
     $a->setFirstName(null);
     $this->assertTrue($a->isModified(), "Expected Author to be modified after changing empty string column value to NULL.");
     $a->setFirstName("John");
     $a->setAge(0);
     $a->save();
     $this->assertFalse($a->isModified(), "Expected Author to be unmodified after saving set values.");
     $a->setAge(null);
     $this->assertTrue($a->isModified(), "Expected Author to be modified after changing 0-value int column to NULL.");
     $a->save();
     $this->assertFalse($a->isModified(), "Expected Author to be unmodified after saving set values.");
     $a->setAge(0);
     $this->assertTrue($a->isModified(), "Expected Author to be modified after changing NULL-value int column to 0.");
 }
开发者ID:JimmyVB,项目名称:Symfony-v1.2,代码行数:43,代码来源:GeneratedObjectTest.php


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