Method to increment the hits for a row if the necessary property/field exists.

@param   mixed    $pk  An optional primary key value to increment. If not set the instance property value is used.
@return  boolean  True on success.
@since   2.1.12
550107
public function hit($pk = null)
	{
		// If there is no hits field, just return true.
		if (!property_exists($this, 'hits'))
		{
			return true;
		}

		// Initialise variables.
		$k = $this->_tbl_key;
		$pk = (is_null($pk)) ? $this->$k : $pk;

		// If no primary key is given, return false.
		if ($pk === null)
		{
			return false;
		}

		// Check the row in by primary key.
		$query = $this->_db->getQuery();
		$query->update($this->_tbl);
		$query->set(array(
			'hits' => new \Hubzero\Database\Value\Raw('(hits + 1)')
		));
		$query->whereEquals($this->_tbl_key, $pk);
		$this->_db->setQuery($query->toString());

		// Check for a database error.
		if (!$this->_db->execute())
		{
			$e = new Exception(Lang::txt('JLIB_DATABASE_ERROR_HIT_FAILED', get_class($this), $this->_db->getErrorMsg()));
			$this->setError($e);
			return false;
		}

		// Set table values in the object.
		$this->hits++;

		return true;
	}
1350843
private static function generatePrimaryKey(array $pk, array $columns)
    {
        if (empty($pk)) {
            return '';
        }
        // Composite primary keys
        if (2 <= count($pk)) {
            $compositePk = implode(', ', $pk);
            return "    'PRIMARY KEY ($compositePk)',\n";
        }
        // Primary key not an auto-increment
        $flag = false;
        foreach ($columns as $column) {
            if ($column->autoIncrement) {
                $flag = true;
            }
        }
        if (false === $flag) {
            return sprintf("    'PRIMARY KEY (%s)',\n", $pk[0]);
        }
        return '';
    }
909071
public function _sqlite_increment_trigger($pkey) {
        $table = $this->db->quotekey($this->name);
        $pkey = $this->db->quotekey($pkey);
        $triggerName = $this->db->quotekey($this->name.'_insert');
        $queries[] = "DROP TRIGGER IF EXISTS $triggerName;";
        $queries[] = 'CREATE TRIGGER '.$triggerName.' AFTER INSERT ON '.$table.
                     ' WHEN (NEW.'.$pkey.' IS NULL) BEGIN'.
                     ' UPDATE '.$table.' SET '.$pkey.' = ('.
                     ' select coalesce( max( '.$pkey.' ), 0 ) + 1 from '.$table.
                     ') WHERE ROWID = NEW.ROWID;'.
                     ' END;';
        return $queries;
    }
1320223
public function increment($key, $val = 1)
    {
        return $this->hash($key)->incrBy($key, abs(intval($val)));
    }
86353
public function increment($key, $offset=1) {
        $cacheKey = $this->buildKey($key);
        $ret = $this->getMemcache()->increment($cacheKey,$offset);
        if (!$ret) {
            $this->getMemcache()->set($cacheKey, 1);
            return 1;
        }
        return $ret;
    }
1146039
public function increment($key, $value = 1)
    {
        return $this->apc->increment($this->prefix.$key, $value);
    }
1272696
public function increment($key, $steps = 1)
    {
        $this->callBeforeListeners('increment', [$this->storageName, $key, $steps]);
        $result = $this->storage->increment($key, $steps);
        $this->callAfterListeners('increment', [$this->storageName, $key, $steps]);

        return $result;
    }
157800
public function updateByPK($pk, $values){
        $pkConditions = $this->buildPKConditions($this->pk, $pk);
        return $this->update($values, $pkConditions[0], $pkConditions[1]);
    }
897413
public function increment($key, $val = 1, $field = null, $tablePrefix = null)
    {
        list($tableName, $condition) = $this->parseKey($key, true);
        if (is_null($field) || empty($tableName) || empty($condition)) {
            return false;
        }
        $val = abs(intval($val));
        is_null($tablePrefix) && $tablePrefix = $this->tablePrefix;
        $tableName = $tablePrefix . $tableName;

        $bulk = new BulkWrite();
        $bulk->update($condition, ['$inc' => [$field => $val]], ['multi' => true]);
        $result = $this->runMongoBulkWrite($tableName, $bulk);

        Cml::$debug && $this->debugLogSql('BulkWrite INC', $tableName, $condition, ['$inc' => [$field => $val]]);

        return $result->getModifiedCount();
    }
968267
public function deleteByPK($pk){
        $pkConditions = $this->buildPKConditions($this->pk, $pk);
        return $this->delete($pkConditions[0], $pkConditions[1]);
    }
499336
public function increment($key, $step = 1)
    {
        if (!$this->enabled)
            return false;

        $has_replaced = $has_set = false;
        try {
            // Store the cache object
            $nKey = $this->key($key);
            $has_replaced = @$this->getConnection()->add($nKey, $step, 0);
            if (!$has_replaced) {
                $has_set = @$this->getConnection()->increment($nKey, $step);
            }

        } catch (Exception $e) {
            throw new CacheException($e->getMessage(), $e->getCode());
        }

        $this->Logger->debug("". (($has_replaced || $has_set) ? "Successfully" : "Failed to") . " increment key '{$key}'\n");
//        $this->Logger->debug($data);

        return $has_replaced ? $step : $has_set;
    }
808032
public function increment(string $member,int $increment = 1) :bool
        {
                return $this->setFieldIncrement($member,$increment);
        }
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;
  }
474677
public function increment($key, $value = 1)
    {
        if ($this->exists($key)) {
            return self::$redis->incrBy($key, $value);
        } else {
            $this->set($key, $value);

            return $value;
        }
    }
156284
public function primary($pkeys) {
        if (empty($pkeys))
            return false;
        if (!is_array($pkeys))
            $pkeys = array($pkeys);
        // single pkey
        $this->increments = $pkeys[0];
        $this->pkeys = $pkeys;
        // drop duplicate pkey definition
        if (array_key_exists($this->increments,$this->columns))
            unset($this->columns[$this->increments]);
        // set flag on new fields
        foreach ($pkeys as $name)
            if(array_key_exists($name,$this->columns))
                $this->columns[$name]->pkey = true;
        // composite key
        if (count($pkeys) > 1) {
            $pkeys_quoted = array_map(array($this->db,'quotekey'), $pkeys);
            $pk_string = implode(', ', $pkeys_quoted);
            if (preg_match('/sqlite2?/', $this->db->driver())) {
                // rebuild table with new primary keys
                $this->rebuild_cmd['pkeys'] = $pkeys;
                return;
            } else {
                $table = $this->db->quotekey($this->name);
                $table_key = $this->db->quotekey($this->name.'_pkey');
                $cmd = array(
                    'odbc' =>
                        "CREATE INDEX $table_key ON $table ( $pk_string );",
                    'mysql' =>
                        "ALTER TABLE $table DROP PRIMARY KEY, ADD PRIMARY KEY ( $pk_string );",
                    'mssql|sybase|dblib|sqlsrv' => array(
                        "ALTER TABLE $table DROP CONSTRAINT PK_".$this->name."_ID;",
                        "ALTER TABLE $table ADD CONSTRAINT $table_key PRIMARY KEY ( $pk_string );",
                    ),
                    'pgsql' => array(
                        "ALTER TABLE $table DROP CONSTRAINT $table_key;",
                        "ALTER TABLE $table ADD CONSTRAINT $table_key PRIMARY KEY ( $pk_string );",
                    ),
                );
                $query = $this->findQuery($cmd);
                if (!is_array($query))
                    $query = array($query);
                foreach ($query as $q)
                    $this->queries[] = $q;
            }
        }
    }
377466
public function isLast($key)
	{
		if ($this->rows && $this->count())
		{
			return $key == array_slice($this->rows, -1, 1)[0]->getPkValue();
		}

		return false;
	}
648002
public function increment($key, $value = 1)
    {
        return $this->memcached->increment($this->prefix.$key, $value);
    }