Permalink
Browse files

Use Criterion always when possible

Using Criterion allows to bind values in statements.
You can't use Criterion only for strings because in this method
you can't distinguish if it is a table name or value provided by user.
  • Loading branch information...
1 parent 0ad1698 commit a6a20bd88fccffb952753919bc0c7b951e3c3b5e @arvenil committed Apr 13, 2013
Showing with 2 additions and 2 deletions.
  1. +1 −1 runtime/lib/query/Criteria.php
  2. +1 −1 test/testsuite/runtime/query/CriteriaTest.php
@@ -963,7 +963,7 @@ public function addMultipleJoin($conditions, $joinType = null)
list($leftTableName, $leftTableAlias) = array(null, null);
$leftColumnName = $left;
}
- if (!is_array($right) && $pos = strrpos($right, '.')) {
+ if (is_string($right) && $pos = strrpos($right, '.')) {
$rightTableAlias = substr($right, 0, $pos);
$rightColumnName = substr($right, $pos + 1);
list($rightTableName, $rightTableAlias) = $this->getTableNameAndAlias($rightTableAlias);
@@ -800,7 +800,7 @@ public function testAddJoinMultipleValue()
addSelectColumn("TABLE_A.id");
$expect = 'SELECT TABLE_A.id FROM TABLE_A INNER JOIN TABLE_B '
- . 'ON (TABLE_A.FOO_ID=TABLE_B.id AND TABLE_A.BAR=3)';
+ . 'ON (TABLE_A.FOO_ID=TABLE_B.id AND TABLE_A.BAR=:p1)';
$params = array();
$result = BasePeer::createSelectSql($c, $params);
$this->assertEquals($expect, $result);

0 comments on commit a6a20bd

Please sign in to comment.