From 4c86659bc90d9134b0f901572c5417aa7d9cec18 Mon Sep 17 00:00:00 2001 From: wei <> Date: Tue, 27 Feb 2007 23:27:14 +0000 Subject: Add comments for scaffold, minor changes to TActiveRecord --- .../Data/ActiveRecord/TActiveRecordCriteria.php | 27 +++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'framework/Data/ActiveRecord/TActiveRecordCriteria.php') diff --git a/framework/Data/ActiveRecord/TActiveRecordCriteria.php b/framework/Data/ActiveRecord/TActiveRecordCriteria.php index 6adfe4ce..533ff50a 100644 --- a/framework/Data/ActiveRecord/TActiveRecordCriteria.php +++ b/framework/Data/ActiveRecord/TActiveRecordCriteria.php @@ -149,14 +149,29 @@ class TActiveRecordCriteria extends TComponent $this->_offset=$value; } + /** + * @return string string representation of the criteria. Useful for debugging. + */ public function __toString() { - return $this->getCondition(); - } - - public function repr() - { - return var_export($this->getParameters()->toArray(),true); + $str = ''; + if(strlen((string)$this->getCondition()) > 0) + $str .= '"'.(string)$this->getCondition().'"'; + $params = array(); + foreach($this->getParameters() as $k=>$v) + $params[] = "{$k} => ${v}"; + if(count($params) > 0) + $str .= ', "'.implode(', ',$params).'"'; + $orders = array(); + foreach($this->getOrdersBy() as $k=>$v) + $orders[] = "{$k} => ${v}"; + if(count($orders) > 0) + $str .= ', "'.implode(', ',$orders).'"'; + if($this->_limit !==null) + $str .= ', '.$this->_limit; + if($this->_offset !== null) + $str .= ', '.$this->_offset; + return $str; } } -- cgit v1.2.3