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

From Woozle Writes Code
< Ferreteria‎ | v0.3‎ | class
Jump to navigation Jump to search
(Created page with "{{page/code/class|ferreteria}} <source lang=php> /*tttt PURPOSE: for enabling sequential access to multiple rows of data Does not implement a method of storing the data....")
 
No edit summary
Line 4: Line 4:
   PURPOSE: for enabling sequential access to multiple rows of data
   PURPOSE: for enabling sequential access to multiple rows of data
     Does not implement a method of storing the 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 {
trait tSequentialAccess {
     // ACTION: sets the row pointer to just before the first row
// ++ DATA CONTROL ++ //
     /*----
      ACTION: sets the row pointer to just before the first row
    */
     abstract public function RewindRows();
     abstract public function RewindRows();
     // RETURNS: number of rows in the resultset
// ++ DATA STATUS ++ //
     abstract public function GetFoundRowCount();
     /*----
     public function IsRowFound() { return ($this->GetFoundRowCount() > 0); }
      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
       ACTION: Retrieves the current row data and advances to the next
Line 16: Line 27:
     */
     */
     abstract public function NextRow();  // load the next row from the source into the fields
     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
       ACTION: For each record in the current record source, the field values
Line 22: Line 36:
       RETURNS: keyed array of field objects
       RETURNS: keyed array of field objects
         array[key][field name] = field object
         array[key][field name] = field object
      HISTORY:
        2018-12-30 replaces SelectRows_asArray(), which was identical
     */
     */
     public function FetchRows_asFieldArray($sField) {
     public function FetchRows_asFieldArray($sField) {
     // ASSUMES: all rows have the same columns
     /*----
     public function DumpRows() {
      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) {
}
}
</source>
</source>
Line 31: Line 52:
* '''used by''':
* '''used by''':
** {{l/ferreteria/class|tInternalStorage}}
** {{l/ferreteria/class|tInternalStorage}}
** {{l/ferreteria/class|cPortalRow_database}}
** {{l/ferreteria/class|tDatabaseStorage}}
** <s>{{l/ferreteria/class|cPortalRow_database}}</s>

Revision as of 14:17, 1 January 2019

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