Find a row by primary key
@param mixed $primaryKey Primary key value
@return \Core\Orm\RowGateway | bool
972866
public function find($primaryKey)
    {
        $where = array(
            $this->_primary => $primaryKey
        );

        $qp = $this->_fetch($where);
        $row = $this->_fetchRow($qp['query'], $qp['params']);
        $className = $this->_rowClass;
        $class = new $className($this);

        if (!$row) {
            return false;
        }

        $class->setData($row);

        return $class;
    }
1296672
public function primaryKey($key = null)
    {
        if ($key !== null) {
            $this->setPrimaryKey($key);
        }

        return $this->getPrimaryKey();
    }
431602
protected function _get($primaryKey)
    {
        $this->hydrateModel($primaryKey);

        return ($this->getModel() instanceof ActiveRecordInterface) ? $this->getModel() : NULL;
    }
1288216
public function pull($key, $default = null)
    {
        $this->items = array_filter($this->items, function ($item) use ($key) {
            $primaryKey = $this->getEntityKey($item);

            return $primaryKey !== $key;
        });
    }
351779
public static function get($entity, $primaryValue)
    {
        $query = new Query($entity);
        $column = self::getInstance()->getEntityStructure($entity)->primaryColumn;
        $query->where($column->name, $primaryValue);
        return $query->one();
    }
1371775
public function getPrimaryKey()
    {
        if (null == $this->primaryKey) {
            foreach ($this->getFields() as $field) {
                if ($field->isPrimaryKey()) {
                    $this->primaryKey = $field;
                    break;
                }
            }
        }
        return $this->primaryKey;
    }
1239585
public function setPrimaryKey( $key )
	{
		if( in_array( $key, $this->fields ) )
		{
			$this->primaryKey = $key;
			return TRUE;
		}
		return FALSE;
	}
1277173
public function update(array $data, $primaryKey)
    {
        $this->normalizeDataColumns($data);

        $this->setSearchIndexableData($data);

        return $this->app['db']->update($this->getTable(), $data, [ $this->getPrimaryKey() => $primaryKey]);
    }
1197349
protected function hydrateModel($primaryKey)
    {
        try {
            $query = $this->prepareQuery();
            $this->model = $this->findPk($query, $primaryKey);
        } catch (\Exception $e) {
            Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR);
        }
    }
894039
public function has(int $primaryKey) : bool
    {
        foreach ($this->rows as $row) {
            if ($row->getColumn($this->primaryKey) === $primaryKey) {
                return true;
            }
        }

        return false;
    }
523698
public function remove(int $primaryKey) : bool
    {
        foreach ($this->rows as $key => $row) {
            if ($row->getColumn($this->primaryKey) === $primaryKey) {
                unset($this->rows[$key]);
                return true;
            }
        }

        return false;
    }
667360
public function findByPK($pk){
        $pkConditions = $this->buildPKConditions($this->pk, $pk);
        return $this->findOne($pkConditions[0], $pkConditions[1]);
    }
995240
public function find( $primaryKeys )
    {
        if ( is_array( $primaryKeys ) )
        {
            $primaryKeys = reset( $primaryKeys );
        }

        $rootId = ( (int) $primaryKeys ) ?: null;

        return $this->createStructure( array(
            'rootId'    => $rootId,
            'extra'     => $this->getExtraMapper()
                                ->findByRoot( $rootId ),
            'rules'     => $this->getRuleMapper()
                                ->findAllByRoot(
                                    $rootId,
                                    $this->getRuleOrder()
                                ),
        ) );
    }
357167
public function find($key = null)
    {
        if (is_null($key)) {
            $key = $this->defaultKey;
        }

        return $this->driver->get($this->getKey($key));
    }
444355
public function getPrimaryKey() {
        return $this->cache(__METHOD__, function() {
            $pk = $this->getConfig('primaryKey');
            $schema = $this->getSchema();

            if ($schema->hasColumn($pk)) {
                return $pk;
            }

            if ($pk = $schema->getPrimaryKey()) {
                return $pk['columns'][0];
            }

            return 'id';
        });
    }
952398
public function getLast($primaryKey)
    {
        if (!isset($this->values[$primaryKey])) {
            throw new OutOfBoundsException(sprintf(
                'The key "%s" does not exist.',
                $primaryKey
            ));
        }

        return end($this->values[$primaryKey]);
    }
525326
public function getOtherRequiredPrimaryKeys(array $primaryKeys)
    {
        $pks = [];
        foreach ($this->getPrimaryKey() as $primaryKey) {
            if ($primaryKey->isNotNull() && !$primaryKey->hasDefaultValue() && !in_array($primaryKey, $primaryKeys, true)) {
                $pks = $primaryKey;
            }
        }

        return $pks;
    }