From 65c9e56c86c45af57e623ed6d2bf502897ba5be7 Mon Sep 17 00:00:00 2001 From: zYne Date: Thu, 7 Sep 2006 21:28:47 +0000 Subject: [PATCH] toArray() added --- Doctrine/Record.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Doctrine/Record.php b/Doctrine/Record.php index 868774d72..828589c99 100644 --- a/Doctrine/Record.php +++ b/Doctrine/Record.php @@ -844,6 +844,24 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite public function getColumnCount() { return $this->count(); } + /** + * toArray + * returns record as an array + * + * @return array + */ + public function toArray() { + $a = array(); + + foreach($this as $column => $value) { + $a[$column] = $value; + } + if($this->table->getIdentifierType() == Doctrine_Identifier::AUTO_INCREMENT) { + $i = $this->table->getIdentifier(); + $a[$i] = $this->getIncremented(); + } + return $a; + } /** * checks if record has data * @return boolean