Ferreteria/v3/class/tDatabaseStorage

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
< Ferreteria‎ | v3‎ | class
Jump to: navigation, search
/*tttt
  CEMENTS tSequentialAccess
  USE WITH: tQueryableSource type
*/
trait tDatabaseStorage {
    use tSequentialAccess;
    
    // ++ DATA CONTROL ++ //

    // CEMENTS: tSequentialAccess
    public function RewindRows() {
	$this->GetDatabase()->Result_Rewind($this);
    }
    
    // -- DATA CONTROL -- //
    // ++ DATA STATUS ++ //

    /*----
      RETURNS: number of rows in the resultset
      CEMENTS: tSequentialAccess
    */
    public function GetRowCount() {
	return $this->GetDatabase()->Result_RowCount($this);
    }
    // CEMENTS: tSequentialAccess
    public function HasRows() {
        return $this->GetRowCount() > 0;
    }

    // -- DATA STATUS -- //
    // ++ DATA READ: BASIC ++ //

    /*----
      ACTION: Retrieves the current row data and advances to the next
      RETURNS: row data as an array, or NULL if no more rows
      CEMENTS: tSequentialAccess
    */
    public function NextRow() {
	$db = $this->GetDatabase();
	$arVals = $db->Result_NextRow($this);
	$ok = FALSE;
	if (!is_null($arVals)) {
	    if (is_array($arVals)) {
                //echo 'THIS:<pre>'.print_r($this,TRUE).'</pre>';
                $op = $this->LoadRow_fromArray($arVals);
		//$this->LoadValues_fromNative($arVals);
		$ok = TRUE;
	    } else {
		throw new exception(
		  'Ferreteria error: Anomalous result from reading a row. Row data: [BEGIN] '
		  .print_r($arVals,TRUE)
		  .'[END] SQL: '
		  .$db->sql
		);
	    }
	}
	if (!$ok) {
            $this->LoadRow_fromArray(array());
        }
	return $arVals;
    }

    // -- DATA READ: BASIC -- //
    // ++ NOT IMPLEMENTED ++ //
    
    // public function FetchRows($sql) : see tQueryableSource
    // public function SelectRows(...) : see tQueryableSource
    // public function GetRow_forKey($id) : see tMonokeyQueryableSource
}