Ferreteria/v0.3/class/tInternalStorage

From Woozle Writes Code
< Ferreteria‎ | v0.3‎ | class
Revision as of 01:41, 29 December 2018 by htyp>Woozle (Created page with "{{page/code/class|ferreteria}} <source lang=php> →‎---- CEMENTS: tSequentialAccess NOTE: should probably be named tInternalSequentialStorage or similar: trait tInternalS...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Template:Page/code/class

/*----
  CEMENTS: tSequentialAccess
  NOTE: should probably be named tInternalSequentialStorage or similar
*/
trait tInternalStorage {
    use tSequentialAccess;

    private $arData = array();
    private $idxData = -1;

    // ++ DATA STATUS ++ //
    
    /*----
      RETURNS: number of rows in the resultset
    */
    public function GetFoundRowCount() {
        return count($this->arData);
    }

    // -- DATA STATUS -- //
    // ++ DATA CONTROL ++ //
    
    /*----
      ACTION: sets the row pointer to just before the first row
    */
    public function RewindRows() {
        $this->idxData = -1;
    }

    // -- DATA CONTROL -- //
    // ++ DATA READ ++ //

    /*----
      ACTION: Retrieves the current row data and advances to the next
      RETURNS: row data as an array, or NULL if no more rows
      CEMENT
    */
    public function NextRow() {
        $this->idxData++;
        $idx = $this->idxData;
        if (array_key_exists($idx,$this->arData)) {
            $arRow = $this->arData[$idx];
            $this->LoadRow_fromArray($arRow);
        } else {
            $arRow = NULL;  // no more rows
        }
        return $arRow;
    }

    // -- DATA READ -- //
    // ++ DATA WRITE ++ //

    /*
      HISTORY:
        2018-11-09 disabled in tIOSource_internal because not sure if it was needed
        2018-11-24 moved from tIOSource_internal to cIORow_internal because fcStackTrace needs it
    */
    protected function SetAllRows(array $ar) {
	$this->arData = $ar;
	$this->RewindRows();
    }

    // -- DATA WRITE -- //
}