In my experience working with propel, I eventually came across a need
for complex joins which the ORM really didn't support very well.
propel is a Table Data Gateway / Row Data Gateway ORM as opposed to
Recess's ActiveRecord
http://propel.phpdb.org
With propel, you can execute some custom sql ...
$sql = "SELECT books.* FROM books WHERE NOT EXISTS (SELECT id FROM
review WHERE book_id =
book.id)";
$stmt = $con->createStatement();
$rs = $stmt->executeQuery($sql, ResultSet::FETCHMODE_NUM);
... then feed the result to a TDG Peer to generate a collection of RDG
Models ...
$books = BookPeer::populateObjects($rs);
So long as the user understands that the populateObjects method
(wherever it resides) expects a resultset containing tablename.* this
seems it might be a useful piece of functionality to bridge the gap
between assuming a user has selecting the proper fields and leaving
them stuck with arrays.
More on propel's custom SQL
http://propel.phpdb.org/trac/wiki/Users/Documentation/1.2/BasicCRUD#UsingCustomSQL
- Kev
On May 20, 12:15 pm, Kris Jordan <
krisjor...@gmail.com> wrote:
> In the next iteration on Models there should be an easier way to get the PDO
> object so you could do something like:
> $car = new Car();
>
> $rows = $car->pdo()->query('SELECT ...');
>
> foreach($rows as $row) {
> print $row['column'];
>
> }
>
> Would be dead simple to do something like that. My question is, is there a
> better way of opening up raw SQL? We could *try* to return actual models but
> the challenge is many raw sql statements are specifically for data that
> isn't a defined Model.
>
> What have you guys needed to use raw SQL for? How was it ugly?
>