thekid/rfc — Issue #11: RFC 0011: Changes to Peer/DataSet/Criteria API
Author: thekid
Created: 2011-10-09 14:09:08+00:00
State: open

Scope of Change
====
The Peer class' method doJoin(), doSelect() and iteratorFor() would be
changed to accept types implementing a new interface instead of only
Criteria objects. A new class Statement implementing this interface
would allow users to build SQL and pass it directly to the API.

Rationale
====
There is currently no way to use the object persistence API with user-
defined SQL queries.

Functionality
====
Currently, the following is possible:

```php
doSelect($criteria);

// Use iteratorFor()
for ($iterator= &$peer->iteratorFor($criteria); $iterator->hasNext(); ) {
$object= &$iterator->next();
}
}
?>
```

The added functionality provides the following equivalents:

```php
doSelect($statement);

// Use iteratorFor()
for ($iterator= &$peer->iteratorFor($statement); $iterator->hasNext(); ) {
$object= &$iterator->next();
}
}
?>
```

Dependencies
====
* rdbms.Statement (class)
Represents an SQL statement

* rdbms.Expression (interface)
Interface that gets implemented both by Statement and Criteria

Related documents
====
- Patch
http://xp-framework.net/downloads/rfc0011.diff

Comments
====
- friebe, Wed Nov 24 16:08:41 CET 2004
Think of a name for the interface

- friebe, Thu Nov 25 09:29:49 CET 2004
Is "Expression" a good word for the interface?

- kiesel, Fri Nov 26 15:39:15 CET 2004
Should the statement be allowed to contain the select-clause? The selected
columns are already defined through the peer, so this seems unneccessary.

- friebe, Mon Dec 27 12:02:00 CET 2004
Initial implementation committed