*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
* 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
- const EXCEPTION_INVALID_DATABASE_RESULT = 0xc00;
- const EXCEPTION_RESULT_UPDATE_FAILED = 0xc01;
+ const EXCEPTION_INVALID_DATABASE_RESULT = 0x1c0;
+ const EXCEPTION_RESULT_UPDATE_FAILED = 0x1c1;
/**
* Current position in array
// 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();
$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;
$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
$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
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
*
*
* @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!");
$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])) {