New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query object (Trac #4) #5071

Closed
elgg-gitbot opened this Issue Feb 17, 2013 · 18 comments

Comments

Projects
None yet
2 participants
@elgg-gitbot

elgg-gitbot commented Feb 17, 2013

Original ticket http://trac.elgg.org/ticket/4 on 38449119-03-05 by trac user icewing, assigned to unknown.

Elgg version:

@elgg-gitbot

This comment has been minimized.

elgg-gitbot commented Feb 17, 2013

trac user marcus wrote on 38466094-03-24

This includes adding smart access controls and active functionality (ref #12)

@elgg-gitbot

This comment has been minimized.

elgg-gitbot commented Feb 17, 2013

trac user marcus wrote on 38466101-02-08

Should also remove the get_access_sql_suffix() placeholder.

@elgg-gitbot

This comment has been minimized.

elgg-gitbot commented Feb 17, 2013

Milestone changed to Elgg 1.0 by trac user marcus on 38466216-06-03

@elgg-gitbot

This comment has been minimized.

elgg-gitbot commented Feb 17, 2013

Milestone changed to Elgg 1.1 by trac user marcus on 38466216-09-15

@elgg-gitbot

This comment has been minimized.

elgg-gitbot commented Feb 17, 2013

Title changed from Retrofit database code to use Query object to Query object by trac user marcus on 38996805-03-30

@elgg-gitbot

This comment has been minimized.

elgg-gitbot commented Feb 17, 2013

trac user marcus wrote on 39328369-03-04

(In [svn:3251]) Refs #4: This is a test

@elgg-gitbot

This comment has been minimized.

elgg-gitbot commented Feb 17, 2013

trac user marcus wrote on 39328421-08-02

Testing commenting

@elgg-gitbot

This comment has been minimized.

elgg-gitbot commented Feb 17, 2013

trac user marcus wrote on 39328445-05-20

Testing commenting

@elgg-gitbot

This comment has been minimized.

elgg-gitbot commented Feb 17, 2013

cash wrote on 40079534-11-16

There is an incomplete simple query object referenced in #1143. This ticket and #1143 should be reviewed with respect to the plans for database interface improvements planned for future versions.

@elgg-gitbot

This comment has been minimized.

elgg-gitbot commented Feb 17, 2013

Milestone changed to Elgg 2.0 by cash on 40079534-11-16

@elgg-gitbot

This comment has been minimized.

elgg-gitbot commented Feb 17, 2013

brettp wrote on 40382984-10-21

2.0 absolutely cannot be released without addressing the ORM issue. The current interface is starting to fall behind what devs want and can easily do.

@elgg-gitbot

This comment has been minimized.

elgg-gitbot commented Feb 17, 2013

cash wrote on 40383026-10-30

Is this providing an interface to the current database tables or are you talking about giving developers the ability to create new tables using the API?

@elgg-gitbot

This comment has been minimized.

elgg-gitbot commented Feb 17, 2013

brettp wrote on 40383410-06-14

I mean providing an interface to the existing tables. I suppose that's not quite a full ORM. Basically the current database interface layer is very soggy and it would make maintenance much easier to DRY it up. I gravitate toward a query / ORM object because that's what I'm used to, but I'm up for any other suggestions.

Elgg Classic allowed and expected plugin authors to create their own tables, and things got out of hand. I'd rather not re-introduce this...

@elgg-gitbot

This comment has been minimized.

elgg-gitbot commented Feb 17, 2013

trac user mrclay wrote on 42037086-11-09

Maybe an explicit list of goals would help move this along. Most of the gains of ORM are generally in creating/querying custom schemas and there's a pretty big performance penalty unless they're hand-tuned, which adds back the complexity that the ORM covered up. On the other end there are OO SQL builders like Zend_Db_Select, but that mostly cleans up some code. Any sufficiently robust ORM solution is going to be heavy as well.

@elgg-gitbot

This comment has been minimized.

elgg-gitbot commented Feb 17, 2013

cash wrote on 42072458-12-31

I see three layers of functions right now:

  1. database access functions (get_data(), delete_data(), update_data())
  2. convenience functions for creating queries (elgg_normalise_plural_options_array())
  3. public API functions: elgg_get_entities()

We get very few requests for additional queries. I can think of two and at least one of those should be implemented in the public API - elgg_get_entities_from_attributes()). The other is querying for entities that do not have a specific metadata.

It would be nice if we could get away from building querying strings throughout the code. If we change that, we could theoretically also support other databases or other drivers for MySQL.

@ewinslow

This comment has been minimized.

Member

ewinslow commented Sep 17, 2014

I still want this.

Doctrine has since interesting work that we could either use, or fork, or draw inspiration from.

http://doctrine-orm.readthedocs.org/en/latest/reference/working-with-associations.html#filtering-collections

@ewinslow

This comment has been minimized.

@ewinslow

This comment has been minimized.

Member

ewinslow commented Feb 17, 2015

Latest thoughts on this are to model the list of entities in the system as a collection and try to expose generic collection methods that can work against mysql as a backend. As a performance enhancement, these collection query methods would be lazily executed.

E.g.:

function getTenMostRecentBlogs(Repository<Entity> $entities) {
  return $entities->query(['type' => 'object', 'subtype' => 'blog'])
      ->orderBy('time_created')->reverse()->slice(0, 10);
}

The benefit of this is also just that the API is a bunch of "standard" collection APIs. There's nothing super specific about Elgg to learn here except the possible properties to use in query and orderBy.

It's easy to see how this Repository API might be switched out with an in-memory implementation for testing, for example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment