Set the real pk request value

If no pk was requested it check if a row is currently loaded

@return bool
970582
protected function realPkSelection(&$pk)
  {
    if ( null === $pk ){
      $pk = $this->row->get($this->tbl_key);
    }
    
    if ( null === $pk ){
      $this->setError( DatabaseHelper::getTranslation('NO_ITEM_SELECTED') );
      return false;
    }
    
    return true;
  }
854746
public function isKeepAlive()
	{
		$nKeepAlive = intval( $this->m_cUCProMain->getXTInstance()->getTValue( UCProConst::CKT_KP_ALIVE ) );
		return ( 1 === $nKeepAlive );
	}
1033003
private function getPkColumn()
    {
        if (isset($this->options[self::GRID_PARAM_PK])) {
            return $this->options[self::GRID_PARAM_PK];
        } else {
            return false;
        }
    }
55690
private function update ()
	{
		$this->before_update();

		$statement = 'UPDATE ' . static::$table_name . ' SET ';

		$sets = [];
		$values = [];

		foreach ($this->storage as $key => $value) {
			if ($value !== null) {
				$sets[] = $this->db->quote_column($key) . ' = ?';
				$values[] = $value;
			}
		}

		$statement .= implode(', ', $sets);

		$pk = $this->primary_key_condition();

		$statement .= ' WHERE ' . $pk->statement;

		$values = array_merge($values, $pk->values->getArrayCopy());

		$result = $this->db->query($statement, $values, 'multi', null, false);

		$this->stored = true;
		$this->updated = false;

		$this->after_update();

		return true;
	}
1352683
public static function set() {
        $keys = func_get_args();
        $session = $_SESSION;

        if (!empty($keys) && !empty($session)) {

            $s = & $session;
            foreach ($keys as $key => $value) {

                if ($key == (Data::count($keys) - 1)) {

                    $s = $keys[Data::count($keys) - 1];
                } else {

                    if (!isset($s[$value])) {
                        $s[$value] = array();
                    }
                    if (isset($s[$value]) && is_array($s[$value])) {
                        $s[$value] = $s[$value];
                    }
                    $s = & $s[$value];
                }
            }

            $_SESSION = $session;
            return true;
        }

        return false;
    }
875371
public function load()
    {
        if (empty($this->unique)) {
            return false;
        }
        foreach($this->unique as $column) {
            if (!isset($this->instance[$column])) {
                return false;
            }
        }

        $table_def = $this->getDefinition();

        $sql = 'SELECT ';
        foreach($this->columns as $name => $definition) {
            if (!isset($table_def[$name])) {
                // underlying table is missing the column
                // constraint only used for select columns
                // if a uniqueness-constraint column is missing
                // this method will and should fail
                continue; 
            }
            $sql .= $this->connection->identifierEscape($name).',';
        }
        $sql = substr($sql,0,strlen($sql)-1);
        
        $sql .= ' FROM '.$this->fq_name.' WHERE 1=1';
        $args = array();
        foreach($this->unique as $name) {
            $sql .= ' AND '.$this->connection->identifierEscape($name).' = ?';
            $args[] = $this->instance[$name];
        }

        $prep = $this->connection->prepare($sql);
        $result = $this->connection->execute($prep, $args);

        if ($this->connection->num_rows($result) > 0) {
            $row = $this->connection->fetch_row($result);
            foreach($this->columns as $name => $definition) {
                if (!isset($row[$name])) continue;
                $this->instance[$name] = $row[$name];
            }
            $this->record_changed = false;

            return true;
        } else {
            return false;
        }
    }
129192
public function fakePostHack() {
    if ($this->isPost()) {
      $altmethod = $this->getPost('_method');
      if ($altmethod && $altmethod != 'POST') {
        if ($this->isValidHttpMethod($altmethod)) {
          $_SERVER['REQUEST_METHOD'] = $altmethod;
          $this->setRawData($this->getPost());
          return true;
        }
      }
    }
  }
418931
protected function loadCache()
    {

        if (empty($this->cacheListing)) return false;

        foreach ($this->cacheListing as $key => $entry) {
            if (!$entry) {
                continue;
            }


            if (!($entry instanceof Entry)) {
                /** @var $entry Entry */
                unset($entry);
                continue;
            }

            /** @var $entry Entry */
            if (!$entry->getId()) {
                unset($this->cacheListing [$key]);
                continue;
            }

            // if there is no value or the time to live is exceeded
            // unset the index and if necessary allocated the memoryblock
            if (!$entry->getData() || ($entry->getTtl() !== self::TTL_UNLIMITED && $entry->getTtl() < time())) {
                if ($entry instanceof Entry) {
                    $entry->delete();
                }

                unset($this->cacheListing [$key]);
                continue;
            }

            $this->list [$key] = $entry->getData();
        }

        return true;
    }
56184
protected function isQueryAttribute()
    {
        if( $query = ($this->settings['query'] ?? NULL) )
        {
            $this->settings['getrow'] = Singleton::class('ZN\Database\DB')->query($query)->row();
        }
    }
1164893
public function isPreparedStatementUsed()
    {
        if ($this->executeMode === self::QUERY_MODE_AUTO) {
            // Mysqli doesn't support client side prepared statement emulation
            if ($this->getAdapter()->getDriver() instanceof ZendMysqliDriver) {
                return false;
            }

            // By default, we use PDO prepared statement emulation
            return true;
        }

        if ($this->executeMode === self::QUERY_MODE_PREPARED) {
            return true;
        }

        return false;
    }
1301068
public function save($force=false)
    {
        if (!self::$_loaded) {
            self::_loadColumns();
        }

        // check for callbacks before validation below
        $calling = get_called_class();
        if (!self::_checkCallback($calling, "before_save", $this)) {
            return false;
        }

        // with all the before callbacks checked, check if its valid
        if (!$this->isValid()) {
            return false;
        }

        $pk         = $calling::isIgnoringCase() ? strtolower($calling::getPK()) : $calling::getPK();
        $pk_value   = array_key_exists($pk, $this->_data) ? $this->_data[$pk] : null;
        $attrs      = $this->_data;

        if (!$pk_value) {
            // if there is a method to get the new primary key value on the class, 
            // call it
            if (method_exists($calling, "getNewPKValue")) {
                $pk_value = $calling::getNewPKValue();
                if (!$this->_data[$pk]) {
                    $this->_data[$pk] = $pk_value;
                }
                $attrs = $this->_data;
            }
        }

        // if found a primary key value, check if exists
        if ($pk_value) {
            $this->_new_rec = !self::find($pk_value);
        }

        $rst    = false;
        $newr   = false;

        if ($this->_new_rec) {
            $newr = true;
            self::_checkCallback($calling, "before_create", $this);
            $rst = $this->_insert($attrs, $calling, $pk, $pk_value);
        } else {
            self::_checkCallback($calling, "before_update", $this);

            // no need to update if there weren't changes
            if (sizeof($this->changed()) < 1 && !$force) {
                Log::log("No changes, not updating");
                $rst = true;
            } else {
                $rst = $this->_update($attrs, $calling, $pk, $pk_value);
            }
        }

        if ($rst) {
            self::_checkCallback($calling, "after_save", $this);
            if ($newr) {
                self::_checkCallback($calling, "after_create", $this);
            } else {
                self::_checkCallback($calling, "after_update", $this);
            }
        }
        $this->_prev_data = $this->_data;
        return $rst;
    }
138334
public function isIgnored()
    {
        // don't ignore primary key
        if ($this->isPrimary) {
            return false;
        }
        // don't ignore when configuration is not set
        if (!$this->getConfig()->get(Formatter::CFG_SKIP_COLUMN_WITH_RELATION)) {
            return false;
        }
        // don't ignore when column has no relation
        if (0 === (count($this->getLocalForeignKeys()) + count($this->getForeignKeys()))) {
            return false;
        }

        return true;
    }
1290823
private function fetchLoadValues(): bool
    {
        $row = $this->result()->fetchRow();
        if (false === $row) {
            $this->originalValues = null;
            $this->values = [];
            return false;
        }
        $this->originalValues = $this->setValuesFromDatafields($row);
        $this->values = $this->originalValues;
        return true;
    }
1129947
public function isValidCallbackRequest()
    {
        if (!$this->isValidHubSignature()) {
            return false;
        }

        $decoded = $this->getDecodedBody();

        $object = isset($decoded['object']) ? $decoded['object'] : null;
        $entry = isset($decoded['entry']) ? $decoded['entry'] : null;

        return $object === 'page' && null !== $entry;
    }
340184
public function checkRegistryRequestsAnswers()
    {
        if ($this->_respTrackData && $this->currentUser instanceof \Gems_User_User) {
            $this->_respTrackData = $this->currentUser->applyGroupMask($this->_respTrackData);
        } else {
            if ($this->db instanceof \Zend_Db_Adapter_Abstract) {
                $this->refresh();
            }
        }

        return (boolean) $this->_respTrackData;
    }
813124
public function hasOnUpdate()
    {
        $database = $this->getTable()->getDatabase();
        if($database instanceof Database &&
               $this->onUpdate === $database->getPlatform()->getDefaultFKOnUpdateBehavior()) {
          return false;
        }

        return ($this->onUpdate !== self::NONE);
    }
1212463
public function current()
    {
        $sKey = key($this->values);

        return (true === isset($this->values[$sKey])) ? $this->values[$sKey] : null;
    }