Added exists() to check for existence of data, getColumnCount() as alias to count() and renamed has() to hasRelation() for clarity
This commit is contained in:
parent
cc94b9392a
commit
11efc8e7cc
@ -618,19 +618,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
$this->modified[] = $name;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* has
|
||||
* method for checking existence of properties and Doctrine_Record references
|
||||
*
|
||||
* @param mixed $name name of the property or reference
|
||||
* @return boolean
|
||||
*/
|
||||
public function has($name) {
|
||||
if(isset($this->data[$name]) || isset($this->id[$name]))
|
||||
return true;
|
||||
|
||||
return $this->table->hasForeignKey($name);
|
||||
}
|
||||
/**
|
||||
* set
|
||||
* method for altering properties and Doctrine_Record references
|
||||
@ -826,6 +814,29 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
public function count() {
|
||||
return count($this->data);
|
||||
}
|
||||
/**
|
||||
* alias for count()
|
||||
*/
|
||||
public function getColumnCount() {
|
||||
return $this->count();
|
||||
}
|
||||
/**
|
||||
* checks if record has data
|
||||
* @return boolean
|
||||
*/
|
||||
public function exists() {
|
||||
return $this->state !== Doctrine_Record::STATE_TCLEAN;
|
||||
}
|
||||
/**
|
||||
* method for checking existence of properties and Doctrine_Record references
|
||||
* @param mixed $name name of the property or reference
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasRelation($name) {
|
||||
if(isset($this->data[$name]) || isset($this->id[$name]))
|
||||
return true;
|
||||
return $this->table->hasForeignKey($name);
|
||||
}
|
||||
/**
|
||||
* getIterator
|
||||
* @return Doctrine_Record_Iterator a Doctrine_Record_Iterator that iterates through the data
|
||||
|
Loading…
x
Reference in New Issue
Block a user