protected function checkIfEntityExists()
    {
        $query = new ReadQuery($this->connection, $this->model, $this->factory, $this->accessor, $this->dispatcher);

        foreach ($this->model->primaryFields() as $field) {
            $value = $this->accessor->getPropertyValue($this->instance, $field->name());

            if ($value === null) {
                return false;
            }

            $query->where($field->name(), $value, '=', 'and');
        }

        return $query->count() > 0;
    }
protected function checkIfEntityExists()
    {
        $query = new ReadQuery($this->connection, $this->model, $this->factory, $this->accessor, $this->dispatcher);

        foreach ($this->model->primaryFields() as $field) {
            $value = $this->accessor->getPropertyValue($this->instance, $field->name());

            if ($value === null) {
                return false;
            }

            $query->where($field->name(), $value, '=', 'and');
        }

        return $query->count() > 0;
    }
protected function checkIfEntityExists ( ) { $ query = new ReadQuery ( $ this -> connection , $ this -> model , $ this -> factory , $ this -> accessor , $ this -> dispatcher ) ; foreach ( $ this -> model -> primaryFields ( ) as $ field ) { $ value = $ this -> accessor -> getPropertyValue ( $ this -> instance , $ field -> name ( ) ) ; if ( $ value === null ) { return false ; } $ query -> where ( $ field -> name ( ) , $ value , '=' , 'and' ) ; } return $ query -> count ( ) > 0 ; }
Returns true if entity exists database

@return int
Returns true if entity exists database