Nette\Database\Table\ActiveRow::accessColumn PHP Метод

accessColumn() публичный Метод

public accessColumn ( $key, $selectColumn = TRUE )
    public function accessColumn($key, $selectColumn = TRUE)
    {
        if ($this->table->accessColumn($key, $selectColumn) && !$this->dataRefreshed) {
            if (!isset($this->table[$this->getSignature()])) {
                throw new Nette\InvalidStateException("Database refetch failed; row with signature '{$this->getSignature()}' does not exist!");
            }
            $this->data = $this->table[$this->getSignature()]->data;
            $this->dataRefreshed = TRUE;
        }
        return isset($this->data[$key]) || array_key_exists($key, $this->data);
    }

Usage Example

Пример #1
0
 /**
  * Returns referenced row.
  * @param  ActiveRow
  * @param  string
  * @param  string|NULL
  * @return ActiveRow|NULL|FALSE NULL if the row does not exist, FALSE if the relationship does not exist
  */
 public function getReferencedTable(ActiveRow $row, $table, $column = NULL)
 {
     if (!$column) {
         $belongsTo = $this->conventions->getBelongsToReference($this->name, $table);
         if (!$belongsTo) {
             return FALSE;
         }
         list($table, $column) = $belongsTo;
     }
     if (!$row->accessColumn($column)) {
         return FALSE;
     }
     $checkPrimaryKey = $row[$column];
     $referenced =& $this->refCache['referenced'][$this->getSpecificCacheKey()]["{$table}.{$column}"];
     $selection =& $referenced['selection'];
     $cacheKeys =& $referenced['cacheKeys'];
     if ($selection === NULL || $checkPrimaryKey !== NULL && !isset($cacheKeys[$checkPrimaryKey])) {
         $this->execute();
         $cacheKeys = array();
         foreach ($this->rows as $row) {
             if ($row[$column] === NULL) {
                 continue;
             }
             $key = $row[$column];
             $cacheKeys[$key] = TRUE;
         }
         if ($cacheKeys) {
             $selection = $this->createSelectionInstance($table);
             $selection->where($selection->getPrimary(), array_keys($cacheKeys));
         } else {
             $selection = array();
         }
     }
     return isset($selection[$checkPrimaryKey]) ? $selection[$checkPrimaryKey] : NULL;
 }
All Usage Examples Of Nette\Database\Table\ActiveRow::accessColumn