[icinga-checkins] icinga.org: icinga-api/mhein/default: * implemented basic result output for livestatus arrays

git at icinga.org git at icinga.org
Tue Jan 12 14:21:31 CET 2010


Module: icinga-api
Branch: mhein/default
Commit: 7cfab3d78b3e01abca37cfbca8f984f1ab3f8915
URL:    https://git.icinga.org/?p=icinga-api.git;a=commit;h=7cfab3d78b3e01abca37cfbca8f984f1ab3f8915

Author: Christian Doebler <christian.doebler at netways.de>
Date:   Wed Dec 23 11:00:57 2009 +0100

* implemented basic result output for livestatus arrays

---

 objects/result/IcingaApiResultLivestatus.php |   23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/objects/result/IcingaApiResultLivestatus.php b/objects/result/IcingaApiResultLivestatus.php
index 70cd8c8..a86004f 100644
--- a/objects/result/IcingaApiResultLivestatus.php
+++ b/objects/result/IcingaApiResultLivestatus.php
@@ -13,6 +13,7 @@ class IcingaApiResultLivestatus
 	 */
 
 	private $searchColumns = array();
+	private $lastRowCombined = false;
 
 	/*
 	 * METHODS
@@ -47,7 +48,6 @@ class IcingaApiResultLivestatus
 	 * @author	Christian Doebler <christian.doebler at netways.de>
 	 */
 	public function setSearchResult (array $data) {
-var_dump($data);
 		$this->resultArray = $data;
 		$this->numResults = count($data);
 		return $this;
@@ -87,12 +87,6 @@ var_dump($data);
 				}
 				break;
  			case self::RESULT_ARRAY:
- 				if ($this->resultArray === false) {
- 					$this->resultArray = $this->searchObject->fetchAll(PDO::FETCH_ASSOC);
- 					if ($this->resultType == self::RESULT_ARRAY && $this->dbType == 'oci') {
- 						$this->resultArray = array_change_key_case($this->resultArray, CASE_LOWER);
- 					}
- 				}
 				if ($this->offset === false) {
 					$this->offset = 0;
 				} else {
@@ -102,6 +96,21 @@ var_dump($data);
 					$this->offset = false;
 				}
 				if ($this->offset !== false) {
+					if ($this->lastRowCombined !== false) {
+						if ($this->offset > $this->lastRowCombined) {
+							$this->resultArray[$this->offset] = array_combine(
+								$this->searchColumns,
+								$this->resultArray[$this->offset]
+							);
+							$this->lastRowCombined = $this->offset;
+						}
+					} else {
+						$this->resultArray[$this->offset] = array_combine(
+							$this->searchColumns,
+							$this->resultArray[$this->offset]
+						);
+						$this->lastRowCombined = 0;
+					}
 					$this->resultRow = $this->resultArray[$this->offset];
 				} else {
 					$this->resultRow = false;





More information about the icinga-checkins mailing list