Rename condition class and fix some namespace statements.

8.0.x
Larry Garfield 2012-01-02 18:25:54 -06:00
parent 05a4376ff4
commit d5b018ce69
12 changed files with 28 additions and 27 deletions

View File

@ -3,7 +3,7 @@
namespace Drupal\Database\Driver\mysql; namespace Drupal\Database\Driver\mysql;
use Drupal\Database\Database; use Drupal\Database\Database;
use Drupal\Database\Query\DatabaseCondition; use Drupal\Database\Query\Condition;
use Drupal\Database\SchemaObjectExistsException; use Drupal\Database\SchemaObjectExistsException;
use Drupal\Database\SchemaObjectDoesNotExistException; use Drupal\Database\SchemaObjectDoesNotExistException;
use Drupal\Database\Schema as DatabaseSchema; use Drupal\Database\Schema as DatabaseSchema;
@ -63,7 +63,7 @@ class Schema extends DatabaseSchema {
$table_info = $this->getPrefixInfo($table_name, $add_prefix); $table_info = $this->getPrefixInfo($table_name, $add_prefix);
$condition = new DatabaseCondition('AND'); $condition = new Condition('AND');
$condition->condition('table_schema', $table_info['database']); $condition->condition('table_schema', $table_info['database']);
$condition->condition('table_name', $table_info['table'], $operator); $condition->condition('table_name', $table_info['table'], $operator);
return $condition; return $condition;

View File

@ -9,7 +9,7 @@ use Countable;
/** /**
* Generic class for a series of conditions in a query. * Generic class for a series of conditions in a query.
*/ */
class DatabaseCondition implements ConditionInterface, Countable { class Condition implements ConditionInterface, Countable {
/** /**
* Array of conditions. * Array of conditions.

View File

@ -22,7 +22,7 @@ class Delete extends Query implements ConditionInterface {
* *
* Condition handling is handled via composition. * Condition handling is handled via composition.
* *
* @var DatabaseCondition * @var Condition
*/ */
protected $condition; protected $condition;
@ -41,7 +41,7 @@ class Delete extends Query implements ConditionInterface {
parent::__construct($connection, $options); parent::__construct($connection, $options);
$this->table = $table; $this->table = $table;
$this->condition = new DatabaseCondition('AND'); $this->condition = new Condition('AND');
} }
/** /**

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Drupal\Database; namespace Drupal\Database\Query;
use Exception; use Exception;

View File

@ -134,7 +134,7 @@ class Merge extends Query implements ConditionInterface {
parent::__construct($connection, $options); parent::__construct($connection, $options);
$this->table = $table; $this->table = $table;
$this->conditionTable = $table; $this->conditionTable = $table;
$this->condition = new DatabaseCondition('AND'); $this->condition = new Condition('AND');
} }
/** /**

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Drupal\Database; namespace Drupal\Database\Query;
use Exception; use Exception;

View File

@ -67,14 +67,14 @@ class Select extends Query implements SelectInterface {
/** /**
* The conditional object for the WHERE clause. * The conditional object for the WHERE clause.
* *
* @var DatabaseCondition * @var Condition
*/ */
protected $where; protected $where;
/** /**
* The conditional object for the HAVING clause. * The conditional object for the HAVING clause.
* *
* @var DatabaseCondition * @var Condition
*/ */
protected $having; protected $having;
@ -119,8 +119,8 @@ class Select extends Query implements SelectInterface {
public function __construct($table, $alias = NULL, Connection $connection, $options = array()) { public function __construct($table, $alias = NULL, Connection $connection, $options = array()) {
$options['return'] = Database::RETURN_STATEMENT; $options['return'] = Database::RETURN_STATEMENT;
parent::__construct($connection, $options); parent::__construct($connection, $options);
$this->where = new DatabaseCondition('AND'); $this->where = new Condition('AND');
$this->having = new DatabaseCondition('AND'); $this->having = new Condition('AND');
$this->addJoin(NULL, $table, $alias); $this->addJoin(NULL, $table, $alias);
} }

View File

@ -36,7 +36,7 @@ class Update extends Query implements ConditionInterface {
* *
* Condition handling is handled via composition. * Condition handling is handled via composition.
* *
* @var DatabaseCondition * @var Condition
*/ */
protected $condition; protected $condition;
@ -70,7 +70,7 @@ class Update extends Query implements ConditionInterface {
parent::__construct($connection, $options); parent::__construct($connection, $options);
$this->table = $table; $this->table = $table;
$this->condition = new DatabaseCondition('AND'); $this->condition = new Condition('AND');
} }
/** /**

View File

@ -2,8 +2,8 @@
namespace Drupal\Database; namespace Drupal\Database;
use Drupal\Database\DatabaseSchemaObjectExistsException; use Drupal\Database\SchemaObjectExistsException;
use Drupal\Database\Query\DatabaseCondition; use Drupal\Database\Query\Condition;
use Drupal\Database\Query\PlaceholderInterface; use Drupal\Database\Query\PlaceholderInterface;
/** /**
@ -286,7 +286,7 @@ abstract class Schema implements PlaceholderInterface {
// Retrive the table name and schema // Retrive the table name and schema
$table_info = $this->getPrefixInfo($table_name, $add_prefix); $table_info = $this->getPrefixInfo($table_name, $add_prefix);
$condition = new DatabaseCondition('AND'); $condition = new Condition('AND');
$condition->condition('table_catalog', $info['database']); $condition->condition('table_catalog', $info['database']);
$condition->condition('table_schema', $table_info['schema']); $condition->condition('table_schema', $table_info['schema']);
$condition->condition('table_name', $table_info['table'], $operator); $condition->condition('table_name', $table_info['table'], $operator);

View File

@ -1,7 +1,7 @@
<?php <?php
use Drupal\Database\Database; use Drupal\Database\Database;
use Drupal\Database\Query\DatabaseCondition; use Drupal\Database\Query\Condition;
/** /**
* @file * @file
@ -530,28 +530,28 @@ function db_next_id($existing_id = 0) {
/** /**
* Returns a new DatabaseCondition, set to "OR" all conditions together. * Returns a new DatabaseCondition, set to "OR" all conditions together.
* *
* @return DatabaseCondition * @return Condition
*/ */
function db_or() { function db_or() {
return new DatabaseCondition('OR'); return new Condition('OR');
} }
/** /**
* Returns a new DatabaseCondition, set to "AND" all conditions together. * Returns a new DatabaseCondition, set to "AND" all conditions together.
* *
* @return DatabaseCondition * @return Condition
*/ */
function db_and() { function db_and() {
return new DatabaseCondition('AND'); return new Condition('AND');
} }
/** /**
* Returns a new DatabaseCondition, set to "XOR" all conditions together. * Returns a new DatabaseCondition, set to "XOR" all conditions together.
* *
* @return DatabaseCondition * @return Condition
*/ */
function db_xor() { function db_xor() {
return new DatabaseCondition('XOR'); return new Condition('XOR');
} }
/** /**
@ -562,10 +562,10 @@ function db_xor() {
* *
* @param $conjunction * @param $conjunction
* The conjunction to use for query conditions (AND, OR or XOR). * The conjunction to use for query conditions (AND, OR or XOR).
* @return DatabaseCondition * @return Condition
*/ */
function db_condition($conjunction) { function db_condition($conjunction) {
return new DatabaseCondition($conjunction); return new Condition($conjunction);
} }
/** /**

View File

@ -92,7 +92,7 @@ class UpdateQuery_sqlite extends UpdateQuery {
$this->removeFieldsInCondition($fields, $this->condition); $this->removeFieldsInCondition($fields, $this->condition);
// Add the inverse of the fields to the condition. // Add the inverse of the fields to the condition.
$condition = new DatabaseCondition('OR'); $condition = new Condition('OR');
foreach ($fields as $field => $data) { foreach ($fields as $field => $data) {
if (is_array($data)) { if (is_array($data)) {
// The field is an expression. // The field is an expression.

View File

@ -4,6 +4,7 @@ use Drupal\Database\Database;
use Drupal\Database\StatementEmpty; use Drupal\Database\StatementEmpty;
use Drupal\Database\StatementInterface; use Drupal\Database\StatementInterface;
use Drupal\Database\TransactionOutOfOrderException; use Drupal\Database\TransactionOutOfOrderException;
use Drupal\Database\TransactionNoActiveException;
use Drupal\Database\Query\Merge; use Drupal\Database\Query\Merge;
use Drupal\Database\Query\InvalidMergeQueryException; use Drupal\Database\Query\InvalidMergeQueryException;
use Drupal\Database\Query\NoFieldsException; use Drupal\Database\Query\NoFieldsException;