Ferreteria/v0.3/class/tDatabaseStorage: Difference between revisions

From Woozle Writes Code
< Ferreteria‎ | v0.3‎ | class
Jump to navigation Jump to search
(Created page with "{{page/obsolete|ferreteria}} <source lang=php> →‎tttt CEMENTS tSequentialAccess USE WITH: tQueryableSource type: trait tDatabaseStorage { use tSequentialAccess;...")
 
(not obsolete; used wrong template)
Line 1: Line 1:
{{page/obsolete|ferreteria}}
{{page/code/class|ferreteria}}
<source lang=php>
<source lang=php>
/*tttt
/*tttt

Revision as of 19:38, 2 January 2019

Template:Page/code/class

/*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
}