Ferreteria/v0.3/class/tSequentialAccess

From Woozle Writes Code
< Ferreteria‎ | v0.3‎ | class
Jump to navigation Jump to search

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) {
}