1
0
mirror of synced 2024-12-13 14:56:01 +03:00

added Doctrine_Record::state()

This commit is contained in:
zYne 2006-10-23 17:34:36 +00:00
parent 7e7a0b879c
commit 0c0e6fd637
3 changed files with 88 additions and 3 deletions

View File

@ -499,6 +499,38 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
final public function getState() {
return $this->_state;
}
/**
* state
* returns / assigns the state of this record
*
* @param integer|string $state if set, this method tries to set the record state to $state
*
* @throws Doctrine_Record_State_Exception if trying to set an unknown state
* @return null|integer
*/
public function state($state = null) {
if($state == null) {
return $this->_state;
}
if(is_integer($state)) {
if($state >= 1 && $state <= 6)
$this->_state = $state;
} elseif(is_string($state)) {
$upper = strtoupper($state);
switch($upper) {
case 'DIRTY':
case 'CLEAN':
case 'TDIRTY':
case 'TCLEAN':
case 'PROXY':
case 'DELETED':
$this->_state = constant('Doctrine_Record::STATE_' . $upper);
break;
}
}
throw new Doctrine_Record_State_Exception('Unknown record state ' . $state);
}
/**
* refresh
* refresh internal data from the database

View File

@ -1,5 +1,29 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
Doctrine::autoload('Doctrine_Exception');
class Doctrine_Record_Exception extends Doctrine_Exception { }
/**
* Doctrine_Exception
*
* @package Doctrine ORM
* @url www.phpdoctrine.com
* @license LGPL
*/
class Doctrine_Record_Exception extends Doctrine_Exception { }

View File

@ -0,0 +1,29 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
Doctrine::autoload('Doctrine_Record_Exception');
/**
* Doctrine_Exception
*
* @package Doctrine ORM
* @url www.phpdoctrine.com
* @license LGPL
*/
class Doctrine_Record_State_Exception extends Doctrine_Record_Exception { }