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

From Woozle Writes Code
< Ferreteria‎ | v0.3‎ | class
Jump to navigation Jump to search
No edit summary
m (8 revisions imported: moving this project here)
 
(5 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{page/code/class|ferreteria}}
{{page/code/class}}
<source lang=php>
<source lang=php>
/*tttt
/*tttt
Line 49: Line 49:
}
}
</source>
</source>
* '''file''': {{l/ferreteria/file|data/portals/rows/base.php}}
* '''file''': {{l/ferreteria/file|data/portals/array/storage.php}}
* '''used by''':
* '''used by''':
** {{l/ferreteria/class|tInternalStorage}}
** {{l/ferreteria/class|tInternalStorage}}
** {{l/ferreteria/class|tDatabaseStorage}}
** {{l/ferreteria/class|tDatabaseStorage}}
** {{l/ferreteria/class|cPortalRow_database}}
** {{l/ferreteria/class|cPortalRow_database}}

Latest revision as of 16:44, 22 May 2022

Template:Page/code/class

/*tttt
  PURPOSE: for enabling sequential access to multiple rows of data
    Does not implement a method of storing the data.
  REQUIRES:
    GetFields() used by DumpRows(), FetchRows_asFieldArray(), FetchRows_asFieldArray(
    GetValue() used by FetchRows_asFieldArray(), SelectColumnValues_asArray(
      fka GetFieldValue() (deprecated)
*/
trait tSequentialAccess {
// ++ DATA CONTROL ++ //
    /*----
      ACTION: sets the row pointer to just before the first row
    */
    abstract public function RewindRows();
// ++ DATA STATUS ++ //
    /*----
      RETURNS: number of rows in the resultset
    */
    abstract public function GetRowCount();
    public function HasRows() { return ($this->GetRowCount() > 0); }
// ++ 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
    */
    abstract public function NextRow();   // load the next row from the source into the fields
    // ASSUMES: all rows have the same columns
    public function DumpRows() {
// ++ DATA READ: UTILITY ++ //
    /*----
      ACTION: For each record in the current record source, the field values
	are added to an array which is keyed by the given field.
      INPUT: $sField = name of field to use as the array key
      RETURNS: keyed array of field objects
        array[key][field name] = field object
      HISTORY:
        2018-12-30 replaces SelectRows_asArray(), which was identical
    */
    public function FetchRows_asFieldArray($sField) {
    /*----
      RETURNS: Array consisting of just the values of the given field as found within the current recordset
      HISTORY:
	2017-05-27 written for title-topic display in VbzCart, because I couldn't find a replacement for ColumnValues_array().
	  This should be equivalent to what ColumnValues_array() used to do.
    */
    public function SelectColumnValues_asArray($sField) {
}