]> git.mxchange.org Git - shipsimu.git/blobdiff - inc/classes/main/result/class_DatabaseResult.php
Fixes for image generation
[shipsimu.git] / inc / classes / main / result / class_DatabaseResult.php
index 33f995e3e4e275544f7eca4ef091476d63e90871..3f8918b79da8c54dc29f1dfad2ddde98cb5857f5 100644 (file)
@@ -19,7 +19,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, UpdateableResult, SeekableIterator {
        // Exception constants
@@ -60,12 +60,6 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Up
                // Call parent constructor
                parent::__construct(__CLASS__);
 
-               // Set part description
-               $this->setObjectDescription("Database result");
-
-               // Create unique ID number
-               $this->generateUniqueId();
-
                // Clean up a little
                $this->removeNumberFormaters();
                $this->removeSystemArray();
@@ -109,7 +103,7 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Up
                $entryKey = $this->key();
 
                // Now get the update criteria array and update all entries
-               foreach ($updateInstance->getUpdateCriteria() as $criteriaKey=>$criteriaValue) {
+               foreach ($updateInstance->getUpdateCriteria() as $criteriaKey => $criteriaValue) {
                        // Update data
                        $this->resultArray['rows'][$entryKey][$criteriaKey] = $criteriaValue;
 
@@ -129,14 +123,11 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Up
                $nextValid = false;
 
                // Is the result valid?
-               if ($this->resultArray['status'] === "ok") {
-                       // The status is fine so let's have a look for the next entry
-                       if ($this->valid()) {
-                               // Next entry found, so count one up and cache it
-                               $this->currentPos++;
-                               $this->currentRow = $this->resultArray['rows'][$this->currentPos];
-                               $nextValid = true;
-                       } // END - if
+               if ($this->valid()) {
+                       // Next entry found, so count one up and cache it
+                       $this->currentPos++;
+                       $this->currentRow = $this->resultArray['rows'][$this->currentPos];
+                       $nextValid = true;
                } // END - if
 
                // Return the result
@@ -189,7 +180,7 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Up
                $isValid = false;
 
                // Check if 
-               if ((isset($this->resultArray['rows'][($this->currentPos + 1)])) && (isset($this->resultArray['rows'][0]))) {
+               if (($this->ifStatusIsOkay()) && (isset($this->resultArray['rows'][($this->currentPos + 1)])) && (isset($this->resultArray['rows'][0]))) {
                        // All fine!
                        $isValid = true;
                } // END - if
@@ -198,6 +189,15 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Up
                return $isValid;
        }
 
+       /**
+        * Determines wether the status of the query was fine ("ok")
+        *
+        * @return      $ifStatusOkay   Wether the status of the query was okay
+        */
+       public function ifStatusIsOkay () {
+               return ((isset($this->resultArray['status'])) && ($this->resultArray['status'] === "ok"));
+       }
+
        /**
         * Gets the current key of iteration
         *
@@ -221,6 +221,7 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Up
         *
         * @param       $criteriaInstance       The criteria to look inside the data set
         * @return      $result                         Found result entry
+        * @todo        0% done
         */
        public function searchEntry (LocalSearchCriteria $criteriaInstance) {
                die(__METHOD__.": Unfinished!");
@@ -317,7 +318,7 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Up
                        $currentEntry = $this->current();
 
                        // Walk only through out-dated columns
-                       foreach ($this->outDated as $key=>$dummy) {
+                       foreach ($this->outDated as $key => $dummy) {
                                // Does this key exist?
                                //* DEBUG: */ echo "outDated: {$key}<br />\n";
                                if (isset($currentEntry[$key])) {