summaryrefslogtreecommitdiff
path: root/framework/Data/ActiveRecord/TActiveRecord.php
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Data/ActiveRecord/TActiveRecord.php')
-rw-r--r--framework/Data/ActiveRecord/TActiveRecord.php29
1 files changed, 24 insertions, 5 deletions
diff --git a/framework/Data/ActiveRecord/TActiveRecord.php b/framework/Data/ActiveRecord/TActiveRecord.php
index 24fa41ce..735579cd 100644
--- a/framework/Data/ActiveRecord/TActiveRecord.php
+++ b/framework/Data/ActiveRecord/TActiveRecord.php
@@ -4,9 +4,8 @@
*
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2013 PradoSoft
+ * @copyright Copyright &copy; 2005-2014 PradoSoft
* @license http://www.pradosoft.com/license/
- * @version $Id: TActiveRecord.php 3245 2013-01-07 20:23:32Z ctrlaltca $
* @package System.Data.ActiveRecord
*/
@@ -142,7 +141,6 @@ Prado::using('System.Data.ActiveRecord.Relations.TActiveRecordRelationContext');
* </code>
*
* @author Wei Zhuo <weizho[at]gmail[dot]com>
- * @version $Id: TActiveRecord.php 3245 2013-01-07 20:23:32Z ctrlaltca $
* @package System.Data.ActiveRecord
* @since 3.1
*/
@@ -1025,6 +1023,29 @@ abstract class TActiveRecord extends TComponent
{
return isset(self::$_relations[get_class($this)][strtolower($property)]);
}
+
+ /**
+ * Return record data as array
+ * @return array of column name and column values
+ * @since 3.2.4
+ */
+ public function toArray(){
+ $result=array();
+ foreach($this->getRecordTableInfo()->getLowerCaseColumnNames() as $columnName){
+ $result[$columnName]=$this->getColumnValue($columnName);
+ }
+
+ return $result;
+ }
+
+ /**
+ * Return record data as JSON
+ * @return JSON
+ * @since 3.2.4
+ */
+ public function toJSON(){
+ return json_encode($this->toArray());
+ }
}
/**
@@ -1037,7 +1058,6 @@ abstract class TActiveRecord extends TComponent
* be set to false to prevent the requested change event to be performed.
*
* @author Wei Zhuo<weizhuo@gmail.com>
- * @version $Id: TActiveRecord.php 3245 2013-01-07 20:23:32Z ctrlaltca $
* @package System.Data.ActiveRecord
* @since 3.1.2
*/
@@ -1072,7 +1092,6 @@ class TActiveRecordChangeEventParameter extends TEventParameter
* - Exception: throws a TActiveRecordException
*
* @author Yves Berkholz <godzilla80@gmx.net>
- * @version $Id: TActiveRecord.php 3245 2013-01-07 20:23:32Z ctrlaltca $
* @package System.Data.ActiveRecord
* @see TActiveRecordManager::setInvalidFinderResult
* @see TActiveRecordConfig::setInvalidFinderResult