[floe] r405 committed - refactoring parameter for quoted strings in where clauses

0 views
Skip to first unread message

fl...@googlecode.com

unread,
May 20, 2010, 8:28:01 AM5/20/10
to floe-c...@googlegroups.com
Revision: 405
Author: coretxt
Date: Thu May 20 05:26:59 2010
Log: refactoring parameter for quoted strings in where clauses
http://code.google.com/p/floe/source/detail?r=405

Modified:
/trunk/src/repository/Query.class.php
/trunk/src/repository/store/mysql/MysqlQuery.class.php

=======================================
--- /trunk/src/repository/Query.class.php Thu May 20 05:22:19 2010
+++ /trunk/src/repository/Query.class.php Thu May 20 05:26:59 2010
@@ -140,21 +140,21 @@
*
* <code>Query::criteria("title", "=", "My Title");</code>
* <code>Query::criteria("count", ">=", 999);</code>
- * @todo fix isJoin parameter hack
+ * @todo fix unquoted parameter hack
* @return stdClass criteria object
*/
- static function criteria($field, $operator, $value, $isJoin=false) {
+ static function criteria($field, $operator, $value, $unquoted=false) {
$criteria = new stdClass;
$criteria->field = Inflect::underscore($field);
$criteria->operator = $operator;
$criteria->value = $value;
- $criteria->isJoin = $isJoin;
+ $criteria->unquoted = $unquoted;
return $criteria;
}

/**
* Add a generic where predicate, matching value against the given
operator.
- *
+ * @todo fix unquoted parameter hack
* @param string $field name of the field to match against
* @param string $operator match operator (=, etc)
* @return Query
@@ -166,8 +166,7 @@

/**
* Add join connection between PK and FK. Eg. trailers.movie_id=movies.id
- * @todo fix isJoin parameter hack
- *
+ * @todo fix unquoted parameter hack
* @param $left, the left key
* @param $right, the right key
* @return Query
=======================================
--- /trunk/src/repository/store/mysql/MysqlQuery.class.php Thu May 20
05:22:19 2010
+++ /trunk/src/repository/store/mysql/MysqlQuery.class.php Thu May 20
05:26:59 2010
@@ -26,10 +26,8 @@
* @ignore
*/
private function mergeClauses($criteria) {
- if ($criteria->isJoin) {
- return "{$criteria->field} {$criteria->operator}
{$criteria->value}";
- }
- return "{$criteria->field} {$criteria->operator} '{$criteria->value}'";
+ $value = ($criteria->unquoted) ?
$criteria->value : "'{$criteria->value}'";
+ return "{$criteria->field} {$criteria->operator} $value";
}

/**

--
You received this message because you are subscribed to the Google Groups "Floe Commits" group.
To post to this group, send email to floe-c...@googlegroups.com.
To unsubscribe from this group, send email to floe-commits...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/floe-commits?hl=en.

Reply all
Reply to author
Forward
0 new messages