Ferreteria/v0.3/class/tInternalStorage: Difference between revisions
< Ferreteria | v0.3 | class
Jump to navigation
Jump to search
m (Woozle moved page Ferreteria/v3/class/tInternalStorage to Ferreteria/v0.3/class/tInternalStorage: version renumbering) |
m (5 revisions imported: moving this project here) |
(No difference)
|
Latest revision as of 16:43, 22 May 2022
/*----
CEMENTS: tSequentialAccess
NOTE: should probably be named tInternalSequentialStorage or similar
*/
trait tInternalStorage {
use tSequentialAccess;
private $arRows = array();
private $idxData = -1;
// ++ DATA STATUS ++ //
/*----
RETURNS: number of rows in the resultset
*/
public function GetRowCount() {
return count($this->arRows);
}
// -- 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 ++ //
// ++ single row
protected function GetRow($key) {
return $this->arRows[$key];
}
/*----
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->GetRow($idx);
$this->LoadRow_fromArray($arRow);
} else {
$arRow = NULL; // no more rows
}
return $arRow;
}
// ++ all rows
protected function GetAllRows() {
return $this->arRows;
}
/*----
HISTORY:
2018-08-05 Empty recordset no longer throws exception
2018-11-09 Adapting for Ferreteria v3
*/
public function GetRows_forAll() {
$rs = $this->SpawnRows();
$ar = $this->GetAllRows();
if (is_array($ar)) {
$rs->SetAllRows($ar);
} else {
//throw new exception('Ferreteria usage error: attempting to GetAllRecords() when there aren\'t any.');
}
return $rs;
}
// -- DATA READ -- //
// ++ DATA WRITE ++ //
// ++ single row
protected function AddRow(cFieldRow $rc) {
$this->arRows[] = $rc;
}
public function SetRow($key,cFieldRow $rc) {
$this->arRows[$key] = $rc;
}
// ++ all rows
/*
HISTORY:
2018-11-09 disabled in tIOSource_internal because not sure if it was needed
2018-11-24 moved from tIOSource_internal to cFieldRow_internal because fcStackTrace needs it
*/
protected function SetAllRows(array $ar) {
$this->arRows = $ar;
$this->RewindRows();
}
// -- DATA WRITE -- //
}
- file: Template:L/ferreteria/file
- uses: Template:L/ferreteria/class
- used by: Template:L/ferreteria/class