Login | Register
My pages Projects Community openCollabNet

Discussions > users > [propel] BasePeer / Criteria changes

Discussion topic

Back to topic list

[propel] BasePeer / Criteria changes


Author hlellelid
Full name Hans Lellelid
Date 2004-01-30 06:50:57 PST
Message I've made some significant changes to BasePeer and Criteria/Criterion as
per an issue that I posted some time ago.

The problem was that Propel wasn't particularly "smart" when it came to
setting values in SQL SELECT statements. It was using the PHP type of
values to guess how they should be transformed when put into the SQL. Of
course this was problematic since PHP is a quite typeless language and
required you to wrap dates in a Date class, e.g., if you wanted them to
get rendered correctly in the SQL. It also was completely unnecessary,
because Propel knows damn well the type for each column in the database
(indeed that's the whole point of generating map classes).

So, now all select operations use prepared statements and use the
Preparedstatement setter (mutator) method that corresponds to the type of
the column -- not of the PHP value being inserted. In effect this means
that doSelect() is now doPSSelect() -- and doPSSelect() has been removed.

So, specifically:

 * BasePeer::doSelect() changed to use PreparedStatement
 * BasePeer::doUpdate() uses PreparedStatement for "WHERE" clause
 * BasePeer::doDelete() uses Preparedstatement for "WHERE" clause
 * BasePeer::doPSSelect() - DELETED
 * Criterion::appendPsTo() - now has all functionality from
SqlExpression::build() and Criterion::appendTo()
 * Criterion::appendTo - DELETED
 * Criterion::toString() - DELETED
 * SqlExpression::build() - DELETED
 * SqlExpression::buildIn() - DELETED
 * SqlExpression::builLike() - DELETED
 * SqlExpression::proce​ssInValues() - DELETED
 * SqlExpression::quoteAndEscape() - DELETED

(The only method left in SqlExpression is buildInnerJoin() which we could
probably also remove, adding functionality to BasePeer::createSelectSql()
to save overhead of loading an additional class file.)

Removing Propel's need to handle values in SQL also allowed me to make the
following changes:

 * DB::escapeText() - DELETED
 * DB::getBooleanString() - DELETED
 * DB::getDateString() - DELETED

Important: I removed the support for LEFT JOIN. This was really
incomplete and was also causing problems -- especially problems w/ other
databases. The best solution (I've learned) is just to perform the
queries manually if things like cross joins are needed.

And on a less-related note, I also changed Criteria to implement
IteratorAggregate (SPL), so you can now do:

foreach($criteria as $columnName => $criterion) {

Cool :)


To unsubscribe, e-mail: users-unsubscribe@pr​opel.tigris.org
For additional commands, e-mail: users-help at propel dot tigris dot org

« Previous message in topic | 1 of 1 | Next message in topic »


Show all messages in topic

[propel] BasePeer / Criteria changes hlellelid Hans Lellelid 2004-01-30 06:50:57 PST
Messages per page: