Ferreteria/v3/class/tMonokeyQueryableSource

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
< Ferreteria‎ | v3‎ | class
Jump to: navigation, search
// PURPOSE: additional things you can do with a single-keyed queryable source
trait tMonokeyQueryableSource {
    // ++ UTILITY ++ //
 
    /*----
      REQUIRES:
        GetKeyName()  : tDataDesign_singleKey
        GetDatabase() : tQueryableSource
        SelectRows()  : tQueryableSource
        GetRowCount() : tSequentialAccess
        HasRows()     : tSequentialAccess
        NextRow()     : tSequentialAccess
        ClearFields() : cFieldRow - PROBABLY USED WRONG HERE
    */
    public function GetRow_forKey($id) {
        //$t = $this->GetSourceObject();
        $t = $this;
	$sqlWhere = $t->GetKeyName().'='.$this->GetDatabase()->SanitizeValue($id);
	$this->SelectRows($sqlWhere);
	if ($this->GetRowCount() == 0) {  // WORKING HERE
            // 2018-12-25 not sure this will ever happen now?
            echo '<b>SQL</b>: '.$this->sql;
            throw new \exception('SelectRows() returned no rows.');
        } else {
            if ($this->HasRows()) {
                $this->NextRow();	        // advance to first (only) row
            } else {
                // 2018-12-25 might need to be Rows->ClearValues()
                $this->ClearValues();	// so HasValues() (formerly HasRow()) will return FALSE
            }
        }
	return $rc;
    }
   // 2017-03-18 created for EventPlex
    public function GetRows_forKeyList($sqlIDs) {
	$sqlWhere = $this->GetKeyName().' IN ('.$sqlIDs.')';
	return $this->SelectRows($sqlWhere);
    }

    // -- UTILITY -- //
}
  • file: data/core/source.php