diff options
| author | Antonio Gallo <tonicucoz@gmail.com> | 2011-05-08 15:26:22 +0000 | 
|---|---|---|
| committer | Antonio Gallo <tonicucoz@gmail.com> | 2011-05-08 15:26:22 +0000 | 
| commit | afc02bc1c3db9ffe8c9bf660c8aa08666752edfb (patch) | |
| tree | 9a02b06b390dd0c1e796474b888e92c245473424 /h-source/Library/Model/Tree.php | |
| parent | 7fdac301801bc44f6fdb343187413bdfd2d5366c (diff) | |
h-source:added new EasyGiant SVN version
Diffstat (limited to 'h-source/Library/Model/Tree.php')
| -rwxr-xr-x | h-source/Library/Model/Tree.php | 25 | 
1 files changed, 14 insertions, 11 deletions
diff --git a/h-source/Library/Model/Tree.php b/h-source/Library/Model/Tree.php index 4dcac8f..56a5db3 100755 --- a/h-source/Library/Model/Tree.php +++ b/h-source/Library/Model/Tree.php @@ -29,7 +29,7 @@ class Model_Tree extends Model_Base {  	//method to create the first part of where clause  	//$index: the index of $this->_tablesArray  	public function createTreeWhere($index) { -		if (isset($this->on)) +		if (!empty($this->on))  		{  			return $this->on;  		} @@ -90,9 +90,9 @@ class Model_Tree extends Model_Base {  		$wherePlus = $this->createWhereClause(); -		if (!isset($this->on)) +		if (empty($this->on))  		{ -			$on = null; +			$on = array();  			if (isset($where) and isset($wherePlus))  			{ @@ -105,7 +105,7 @@ class Model_Tree extends Model_Base {  		}  		else  		{ -			$on = (strcmp($where,'-') !== 0) ? $where : null; +			$on = (isset($where[0]) and strcmp($where[0],'-') !== 0) ? $where : array();  			$where = $wherePlus;  		} @@ -128,7 +128,7 @@ class Model_Tree extends Model_Base {  		$queryFields = (strcmp($fields,'') === 0) ? $elements['fields'] : $fields; -		return $row = $this->db->select($elements['tables'],$queryFields,$elements['where'],$this->groupBy,$this->orderBy,$this->limit,$elements['on'],$this->using); +		return $row = $this->db->select($elements['tables'],$queryFields,$elements['where'],$this->groupBy,$this->orderBy,$this->limit,$elements['on'],$this->using,$this->join);  	}  	public function send() @@ -158,6 +158,7 @@ class Model_Tree extends Model_Base {  	//$id: the id (primary key) of the record  	//$fields: the comma separated list of fields that have to be extracted  	public function selectId($id,$fields = null) { +		$tempWhere = $this->where;  		$this->setWhereQueryClause(array($this->_idFieldsArray[0] => (int)$id));  		$this->using = null; @@ -170,6 +171,8 @@ class Model_Tree extends Model_Base {  		{  			$values = $this->getAll('other');  		} + +		$this->where = $tempWhere;  		return (count($values) > 0) ? $values[0][$this->_tablesArray[0]] : array(); @@ -179,38 +182,38 @@ class Model_Tree extends Model_Base {  	//the number of records of the table $tableName is returned  	public function rowNumber() {  		$elements = $this->treeQueryElements($this->_tablesArray[0]); -		return $this->db->get_num_rows($elements['tables'],$elements['where'],$this->groupBy,$elements['on'],$this->using); +		return $this->db->get_num_rows($elements['tables'],$elements['where'],$this->groupBy,$elements['on'],$this->using,$this->join);  	}  	public function getMax($field)  	{  		$elements = $this->treeQueryElements($this->_tablesArray[0]); -		return $this->db->getMax($elements['tables'],$field,$elements['where'],$this->groupBy,$elements['on'],$this->using); +		return $this->db->getMax($elements['tables'],$field,$elements['where'],$this->groupBy,$elements['on'],$this->using,$this->join);  	}  	public function getMin($field)  	{  		$elements = $this->treeQueryElements($this->_tablesArray[0]); -		return $this->db->getMin($elements['tables'],$field,$elements['where'],$this->groupBy,$elements['on'],$this->using); +		return $this->db->getMin($elements['tables'],$field,$elements['where'],$this->groupBy,$elements['on'],$this->using,$this->join);  	}  	public function getSum($field)  	{  		$elements = $this->treeQueryElements($this->_tablesArray[0]); -		return $this->db->getSum($elements['tables'],$field,$elements['where'],$this->groupBy,$elements['on'],$this->using); +		return $this->db->getSum($elements['tables'],$field,$elements['where'],$this->groupBy,$elements['on'],$this->using,$this->join);  	}  	public function getAvg($field)  	{  		$elements = $this->treeQueryElements($this->_tablesArray[0]); -		return $this->db->getAvg($elements['tables'],$field,$elements['where'],$this->groupBy,$elements['on'],$this->using); +		return $this->db->getAvg($elements['tables'],$field,$elements['where'],$this->groupBy,$elements['on'],$this->using,$this->join);  	}  	//check if the table has the field $field equal to $value  	public function has($field,$value)  	{  		$elements = $this->treeQueryElements($this->_tablesArray[0]); -		return $this->db->recordExists($elements['tables'],$field,$value,$elements['where'],$this->groupBy,$elements['on'],$this->using); +		return $this->db->recordExists($elements['tables'],$field,$value,$elements['where'],$this->groupBy,$elements['on'],$this->using,$this->join);  	}  // 	//get the number of records of the table $this->_tablesArray[0]  | 
