Browse Source

Merge pull request #1322 from pmoust/master

swapped docs and Exception to type InvalidParamException
tags/2.0.0-beta
Qiang Xue 11 years ago
parent
commit
ca4a12fdba
  1. 5
      extensions/sphinx/QueryBuilder.php
  2. 8
      framework/yii/db/QueryBuilder.php

5
extensions/sphinx/QueryBuilder.php

@ -7,6 +7,7 @@
namespace yii\sphinx; namespace yii\sphinx;
use yii\base\InvalidParamException;
use yii\base\Object; use yii\base\Object;
use yii\db\Exception; use yii\db\Exception;
use yii\db\Expression; use yii\db\Expression;
@ -760,12 +761,12 @@ class QueryBuilder extends Object
* operator is `LIKE` or `OR LIKE` and empty if operator is `NOT LIKE` or `OR NOT LIKE`. * operator is `LIKE` or `OR LIKE` and empty if operator is `NOT LIKE` or `OR NOT LIKE`.
* @param array $params the binding parameters to be populated * @param array $params the binding parameters to be populated
* @return string the generated SQL expression * @return string the generated SQL expression
* @throws Exception if wrong number of operands have been given. * @throws InvalidParamException if wrong number of operands have been given.
*/ */
public function buildLikeCondition($indexes, $operator, $operands, &$params) public function buildLikeCondition($indexes, $operator, $operands, &$params)
{ {
if (!isset($operands[0], $operands[1])) { if (!isset($operands[0], $operands[1])) {
throw new Exception("Operator '$operator' requires two operands."); throw new InvalidParamException("Operator '$operator' requires two operands.");
} }
list($column, $values) = $operands; list($column, $values) = $operands;

8
framework/yii/db/QueryBuilder.php

@ -300,7 +300,7 @@ class QueryBuilder extends \yii\base\Object
{ {
return "DROP TABLE " . $this->db->quoteTableName($table); return "DROP TABLE " . $this->db->quoteTableName($table);
} }
/** /**
* Builds a SQL statement for adding a primary key constraint to an existing table. * Builds a SQL statement for adding a primary key constraint to an existing table.
* @param string $name the name of the primary key constraint. * @param string $name the name of the primary key constraint.
@ -317,12 +317,12 @@ class QueryBuilder extends \yii\base\Object
foreach ($columns as $i => $col) { foreach ($columns as $i => $col) {
$columns[$i] = $this->db->quoteColumnName($col); $columns[$i] = $this->db->quoteColumnName($col);
} }
return 'ALTER TABLE ' . $this->db->quoteTableName($table) . ' ADD CONSTRAINT ' return 'ALTER TABLE ' . $this->db->quoteTableName($table) . ' ADD CONSTRAINT '
. $this->db->quoteColumnName($name) . ' PRIMARY KEY (' . $this->db->quoteColumnName($name) . ' PRIMARY KEY ('
. implode(', ', $columns). ' )'; . implode(', ', $columns). ' )';
} }
/** /**
* Builds a SQL statement for removing a primary key constraint to an existing table. * Builds a SQL statement for removing a primary key constraint to an existing table.
* @param string $name the name of the primary key constraint to be removed. * @param string $name the name of the primary key constraint to be removed.
@ -999,7 +999,7 @@ class QueryBuilder extends \yii\base\Object
* operator is `LIKE` or `OR LIKE` and empty if operator is `NOT LIKE` or `OR NOT LIKE`. * operator is `LIKE` or `OR LIKE` and empty if operator is `NOT LIKE` or `OR NOT LIKE`.
* @param array $params the binding parameters to be populated * @param array $params the binding parameters to be populated
* @return string the generated SQL expression * @return string the generated SQL expression
* @throws Exception if wrong number of operands have been given. * @throws InvalidParamException if wrong number of operands have been given.
*/ */
public function buildLikeCondition($operator, $operands, &$params) public function buildLikeCondition($operator, $operands, &$params)
{ {

Loading…
Cancel
Save