Ferreteria/v0.3/class/tInternalStorage: Difference between revisions
< Ferreteria | v0.3 | class
Jump to navigation
Jump to search
(Created page with "{{page/code/class|ferreteria}} <source lang=php> →---- CEMENTS: tSequentialAccess NOTE: should probably be named tInternalSequentialStorage or similar: trait tInternalS...") |
m (5 revisions imported: moving this project here) |
||
| (4 intermediate revisions by one other user not shown) | |||
| Line 8: | Line 8: | ||
use tSequentialAccess; | use tSequentialAccess; | ||
private $ | private $arRows = array(); | ||
private $idxData = -1; | private $idxData = -1; | ||
| Line 16: | Line 16: | ||
RETURNS: number of rows in the resultset | RETURNS: number of rows in the resultset | ||
*/ | */ | ||
public function | public function GetRowCount() { | ||
return count($this-> | return count($this->arRows); | ||
} | } | ||
| Line 33: | Line 33: | ||
// ++ DATA READ ++ // | // ++ DATA READ ++ // | ||
// ++ single row | |||
protected function GetRow($key) { | |||
return $this->arRows[$key]; | |||
} | |||
/*---- | /*---- | ||
ACTION: Retrieves the current row data and advances to the next | ACTION: Retrieves the current row data and advances to the next | ||
| Line 42: | Line 47: | ||
$idx = $this->idxData; | $idx = $this->idxData; | ||
if (array_key_exists($idx,$this->arData)) { | if (array_key_exists($idx,$this->arData)) { | ||
$arRow = $this-> | $arRow = $this->GetRow($idx); | ||
$this->LoadRow_fromArray($arRow); | $this->LoadRow_fromArray($arRow); | ||
} else { | } else { | ||
| Line 48: | Line 53: | ||
} | } | ||
return $arRow; | 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 READ -- // | ||
// ++ DATA WRITE ++ // | // ++ 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: | HISTORY: | ||
2018-11-09 disabled in tIOSource_internal because not sure if it was needed | 2018-11-09 disabled in tIOSource_internal because not sure if it was needed | ||
2018-11-24 moved from tIOSource_internal to | 2018-11-24 moved from tIOSource_internal to cFieldRow_internal because fcStackTrace needs it | ||
*/ | */ | ||
protected function SetAllRows(array $ar) { | protected function SetAllRows(array $ar) { | ||
$this-> | $this->arRows = $ar; | ||
$this->RewindRows(); | $this->RewindRows(); | ||
} | } | ||
| Line 66: | Line 103: | ||
} | } | ||
</source> | </source> | ||
* '''file''': {{l/ferreteria/file|data/portals/rows/ | * '''file''': {{l/ferreteria/file|data/portals/rows/storage.php}} | ||
* '''uses''': {{l/ferreteria/class|tSequentialAccess}} | * '''uses''': {{l/ferreteria/class|tSequentialAccess}} | ||
* '''used by''': {{l/ferreteria/class|cIORowMemory}} | * '''used by''': {{l/ferreteria/class|cIORowMemory}} | ||
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