1
0
mirror of synced 2024-12-13 14:56:01 +03:00

new DQL aggregate value model

This commit is contained in:
zYne 2006-12-21 22:06:08 +00:00
parent 12dc05fac5
commit 7b48189ba5
24 changed files with 390 additions and 128 deletions

View File

@ -33,6 +33,49 @@
* @version $Revision$ * @version $Revision$
*/ */
final class Doctrine { final class Doctrine {
/**
* ERROR CONSTANTS
*/
const ERR = -1;
const ERR_SYNTAX = -2;
const ERR_CONSTRAINT = -3;
const ERR_NOT_FOUND = -4;
const ERR_ALREADY_EXISTS = -5;
const ERR_UNSUPPORTED = -6;
const ERR_MISMATCH = -7;
const ERR_INVALID = -8;
const ERR_NOT_CAPABLE = -9;
const ERR_TRUNCATED = -10;
const ERR_INVALID_NUMBER = -11;
const ERR_INVALID_DATE = -12;
const ERR_DIVZERO = -13;
const ERR_NODBSELECTED = -14;
const ERR_CANNOT_CREATE = -15;
const ERR_CANNOT_DELETE = -16;
const ERR_CANNOT_DROP = -17;
const ERR_NOSUCHTABLE = -18;
const ERR_NOSUCHFIELD = -19;
const ERR_NEED_MORE_DATA = -20;
const ERR_NOT_LOCKED = -21;
const ERR_VALUE_COUNT_ON_ROW = -22;
const ERR_INVALID_DSN = -23;
const ERR_CONNECT_FAILED = -24;
const ERR_EXTENSION_NOT_FOUND = -25;
const ERR_NOSUCHDB = -26;
const ERR_ACCESS_VIOLATION = -27;
const ERR_CANNOT_REPLACE = -28;
const ERR_CONSTRAINT_NOT_NULL = -29;
const ERR_DEADLOCK = -30;
const ERR_CANNOT_ALTER = -31;
const ERR_MANAGER = -32;
const ERR_MANAGER_PARSE = -33;
const ERR_LOADMODULE = -34;
const ERR_INSUFFICIENT_DATA = -35;
/**
* class naming error
*/
const ERR_CLASS_NAME = -36;
/** /**
* ATTRIBUTE CONSTANTS * ATTRIBUTE CONSTANTS
*/ */
@ -353,12 +396,12 @@ final class Doctrine {
* @return boolean * @return boolean
*/ */
public static function autoload($classname) { public static function autoload($classname) {
if(! self::$path)
self::$path = dirname(__FILE__);
if(class_exists($classname)) if(class_exists($classname))
return false; return false;
if(! self::$path)
self::$path = dirname(__FILE__);
$class = self::$path.DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR,$classname) . '.php'; $class = self::$path.DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR,$classname) . '.php';
if( ! file_exists($class)) if( ! file_exists($class))
@ -366,6 +409,7 @@ final class Doctrine {
require_once($class); require_once($class);
return true; return true;
} }
/** /**
@ -394,7 +438,7 @@ final class Doctrine {
*/ */
public static function isValidClassname($classname) { public static function isValidClassname($classname) {
if(preg_match('~(^[a-z])|(_[a-z])|([\W])|(_{2})~', $classname)) if(preg_match('~(^[a-z])|(_[a-z])|([\W])|(_{2})~', $classname))
throw new Doctrine_Exception("Class name is not valid. Use camel case and underscores (i.e My_PerfectClass)."); return false;
return true; return true;
} }

View File

@ -597,12 +597,14 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
return $this->dbh->query($query); return $this->dbh->query($query);
} }
/** /**
* execute
* @param string $query sql query * @param string $query sql query
* @param array $params query parameters * @param array $params query parameters
* *
* @return PDOStatement * @return PDOStatement|Doctrine_Adapter_Statement
*/ */
public function execute($query, array $params = array()) { public function execute($query, array $params = array()) {
try {
if( ! empty($params)) { if( ! empty($params)) {
$stmt = $this->dbh->prepare($query); $stmt = $this->dbh->prepare($query);
$stmt->execute($params); $stmt->execute($params);
@ -610,6 +612,48 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
} else { } else {
return $this->dbh->query($query); return $this->dbh->query($query);
} }
} catch(Doctrine_Adapter_Exception $e) {
$this->rethrowException($e);
} catch(PDOException $e) {
$this->rethrowException($e);
}
}
/**
* exec
* @param string $query sql query
* @param array $params query parameters
*
* @return PDOStatement|Doctrine_Adapter_Statement
*/
public function exec($query, array $params = array()) {
try {
if( ! empty($params)) {
$stmt = $this->dbh->prepare($query);
$stmt->execute($params);
return $stmt;
} else {
return $this->dbh->exec($query);
}
} catch(Doctrine_Adapter_Exception $e) {
} catch(PDOException $e) { }
$this->rethrowException($e);
}
/**
* rethrowException
*
* @throws Doctrine_Connection_Exception
*/
private function rethrowException(Exception $e) {
$name = 'Doctrine_Connection_' . $this->driverName . '_Exception';
$exc = new $name($e->getMessage(), (int) $e->getCode());
if( ! is_array($e->errorInfo))
$e->errorInfo = array();
$exc->errorInfo = $exc->processErrorInfo($e->errorInfo);
throw $exc;
} }
/** /**
* hasTable * hasTable

View File

@ -68,7 +68,6 @@ class Doctrine_Connection_Exception extends Doctrine_Exception {
Doctrine::ERR_TRUNCATED => 'truncated', Doctrine::ERR_TRUNCATED => 'truncated',
Doctrine::ERR_DEADLOCK => 'deadlock detected', Doctrine::ERR_DEADLOCK => 'deadlock detected',
); );
/** /**
* Return a textual error message for a Doctrine error code * Return a textual error message for a Doctrine error code
* *

View File

@ -51,7 +51,7 @@ class Doctrine_Export extends Doctrine_Connection_Module {
* @return void * @return void
*/ */
public function dropTable($table) { public function dropTable($table) {
$this->conn->getDbh()->query('DROP TABLE ' . $table); $this->conn->execute('DROP TABLE ' . $table);
} }
/** /**
@ -63,7 +63,7 @@ class Doctrine_Export extends Doctrine_Connection_Module {
*/ */
public function dropIndex($table, $name) { public function dropIndex($table, $name) {
$name = $this->conn->quoteIdentifier($this->conn->getIndexName($name), true); $name = $this->conn->quoteIdentifier($this->conn->getIndexName($name), true);
return $this->conn->getDbh()->exec('DROP INDEX ' . $name); return $this->conn->exec('DROP INDEX ' . $name);
} }
/** /**
* drop existing constraint * drop existing constraint
@ -76,7 +76,7 @@ class Doctrine_Export extends Doctrine_Connection_Module {
public function dropConstraint($table, $name, $primary = false) { public function dropConstraint($table, $name, $primary = false) {
$table = $this->conn->quoteIdentifier($table, true); $table = $this->conn->quoteIdentifier($table, true);
$name = $this->conn->quoteIdentifier($this->conn->getIndexName($name), true); $name = $this->conn->quoteIdentifier($this->conn->getIndexName($name), true);
return $this->conn->getDbh()->exec('ALTER TABLE ' . $table . ' DROP CONSTRAINT ' . $name); return $this->conn->exec('ALTER TABLE ' . $table . ' DROP CONSTRAINT ' . $name);
} }
/** /**
* drop existing sequence * drop existing sequence
@ -142,7 +142,7 @@ class Doctrine_Export extends Doctrine_Connection_Module {
$name = $this->conn->quoteIdentifier($name, true); $name = $this->conn->quoteIdentifier($name, true);
$query = 'CREATE TABLE ' . $name . ' (' . $queryFields . ')'; $query = 'CREATE TABLE ' . $name . ' (' . $queryFields . ')';
return $this->conn->getDbh()->exec($query); return $this->conn->exec($query);
} }
/** /**
* create sequence * create sequence
@ -191,7 +191,7 @@ class Doctrine_Export extends Doctrine_Connection_Module {
$fields[] = $this->conn->quoteIdentifier($field, true); $fields[] = $this->conn->quoteIdentifier($field, true);
} }
$query .= ' ('. implode(', ', $fields) . ')'; $query .= ' ('. implode(', ', $fields) . ')';
return $this->conn->getDbh()->exec($query); return $this->conn->exec($query);
} }
/** /**
* Get the stucture of a field into an array * Get the stucture of a field into an array
@ -226,7 +226,7 @@ class Doctrine_Export extends Doctrine_Connection_Module {
* @return void * @return void
*/ */
public function createIndex($table, $name, array $definition) { public function createIndex($table, $name, array $definition) {
return $this->conn->getDbh()->query($this->createIndexSql($table, $name, $definition)); return $this->conn->execute($this->createIndexSql($table, $name, $definition));
} }
/** /**
* Get the stucture of a field into an array * Get the stucture of a field into an array
@ -363,7 +363,7 @@ class Doctrine_Export extends Doctrine_Connection_Module {
* @return void * @return void
*/ */
public function alterTable($name, array $changes, $check) { public function alterTable($name, array $changes, $check) {
$this->conn->getDbh()->query($this->alterTableSql($name, $changes, $check)); $this->conn->execute($this->alterTableSql($name, $changes, $check));
} }
/** /**
* alter an existing table * alter an existing table
@ -589,7 +589,7 @@ class Doctrine_Export extends Doctrine_Connection_Module {
* *
* @return void * @return void
*/ */
public static function export() { public static function exportAll() {
$parent = new ReflectionClass('Doctrine_Record'); $parent = new ReflectionClass('Doctrine_Record');
$conn = Doctrine_Manager::getInstance()->getCurrentConnection(); $conn = Doctrine_Manager::getInstance()->getCurrentConnection();
$old = $conn->getAttribute(Doctrine::ATTR_CREATE_TABLES); $old = $conn->getAttribute(Doctrine::ATTR_CREATE_TABLES);
@ -604,4 +604,40 @@ class Doctrine_Export extends Doctrine_Connection_Module {
} }
$conn->setAttribute(Doctrine::ATTR_CREATE_TABLES, $old); $conn->setAttribute(Doctrine::ATTR_CREATE_TABLES, $old);
} }
public function export($record) {
if( ! $record instanceof Doctrine_Record)
$record = new $record();
$table = $record->getTable();
$reporter = new Doctrine_Reporter();
if( ! Doctrine::isValidClassname($table->getComponentName())) {
$reporter->add(E_WARNING, Doctrine::ERR_CLASS_NAME);
}
try {
$columns = array();
foreach($table->getColumns() as $name => $column) {
$definition = $column[2];
$definition['type'] = $column[0];
$definition['length'] = $column[1];
if($definition['type'] == 'enum' && isset($definition['default']))
$definition['default'] = $table->enumIndex($name, $definition['default']);
if($definition['type'] == 'boolean' && isset($definition['default']))
$definition['default'] = (int) $definition['default'];
$columns[$name] = $definition;
}
$this->createTable($table->getTableName(), $columns);
} catch(Doctrine_Connection_Exception $e) {
$reporter->add(E_ERROR, $e->getCode());
}
return $reporter;
}
} }

View File

@ -89,7 +89,7 @@ class Doctrine_Export_Firebird extends Doctrine_Export {
IF (NEW.' . $name . ' IS NULL OR NEW.' . $name . ' = 0) THEN IF (NEW.' . $name . ' IS NULL OR NEW.' . $name . ' = 0) THEN
NEW.' . $name . ' = GEN_ID('.$sequence_name.', 1); NEW.' . $name . ' = GEN_ID('.$sequence_name.', 1);
END'; END';
$result = $this->conn->getDbh()->exec($triggerSql); $result = $this->conn->exec($triggerSql);
// TODO ? $this->_silentCommit(); // TODO ? $this->_silentCommit();
@ -114,7 +114,7 @@ class Doctrine_Export_Firebird extends Doctrine_Export {
//remove autoincrement trigger associated with the table //remove autoincrement trigger associated with the table
$table = $this->conn->getDbh()->quote(strtoupper($table)); $table = $this->conn->getDbh()->quote(strtoupper($table));
$trigger_name = $this->conn->getDbh()->quote(strtoupper($table) . '_AUTOINCREMENT_PK'); $trigger_name = $this->conn->getDbh()->quote(strtoupper($table) . '_AUTOINCREMENT_PK');
$result = $this->conn->getDbh()->exec("DELETE FROM RDB\$TRIGGERS WHERE UPPER(RDB\$RELATION_NAME)=$table AND UPPER(RDB\$TRIGGER_NAME)=$trigger_name"); $result = $this->conn->exec("DELETE FROM RDB\$TRIGGERS WHERE UPPER(RDB\$RELATION_NAME)=$table AND UPPER(RDB\$TRIGGER_NAME)=$trigger_name");
/** /**
if (PEAR::isError($result)) { if (PEAR::isError($result)) {
@ -441,7 +441,7 @@ class Doctrine_Export_Firebird extends Doctrine_Export {
} }
$query .= ' ('.implode(', ', $fields) . ')'; $query .= ' ('.implode(', ', $fields) . ')';
$result = $this->conn->getDbh()->exec($query); $result = $this->conn->exec($query);
// todo: $this->_silentCommit(); // todo: $this->_silentCommit();
return $result; return $result;
} }
@ -489,7 +489,7 @@ class Doctrine_Export_Firebird extends Doctrine_Export {
$fields[] = $this->conn->quoteIdentifier($field, true); $fields[] = $this->conn->quoteIdentifier($field, true);
} }
$query .= ' ('. implode(', ', $fields) . ')'; $query .= ' ('. implode(', ', $fields) . ')';
$result = $this->conn->getDbh()->exec($query); $result = $this->conn->exec($query);
// TODO ? $this->_silentCommit(); // TODO ? $this->_silentCommit();
return $result; return $result;
} }
@ -503,9 +503,9 @@ class Doctrine_Export_Firebird extends Doctrine_Export {
public function createSequence($seqName, $start = 1) { public function createSequence($seqName, $start = 1) {
$sequenceName = $this->conn->getSequenceName($seqName); $sequenceName = $this->conn->getSequenceName($seqName);
$this->conn->getDbh()->exec('CREATE GENERATOR ' . $sequenceName); $this->conn->exec('CREATE GENERATOR ' . $sequenceName);
$this->conn->getDbh()->exec('SET GENERATOR ' . $sequenceName . ' TO ' . ($start-1)); $this->conn->exec('SET GENERATOR ' . $sequenceName . ' TO ' . ($start-1));
$this->dropSequence($seqName); $this->dropSequence($seqName);
} }
@ -519,6 +519,6 @@ class Doctrine_Export_Firebird extends Doctrine_Export {
$sequence_name = $this->conn->getSequenceName($seq_name); $sequence_name = $this->conn->getSequenceName($seq_name);
$sequence_name = $this->conn->getDbh()->quote($sequence_name); $sequence_name = $this->conn->getDbh()->quote($sequence_name);
$query = "DELETE FROM RDB\$GENERATORS WHERE UPPER(RDB\$GENERATOR_NAME)=$sequence_name"; $query = "DELETE FROM RDB\$GENERATORS WHERE UPPER(RDB\$GENERATOR_NAME)=$sequence_name";
return $this->conn->getDbh()->exec($query); return $this->conn->exec($query);
} }
} }

View File

@ -158,22 +158,18 @@ class Doctrine_Export_Mssql extends Doctrine_Export {
case 'rename': case 'rename':
case 'change': case 'change':
default: default:
return $db->raiseError(MDB2_ERROR_CANNOT_ALTER, null, null, return $db->raiseError(Doctrine::ERR_CANNOT_ALTER, null, null,
'alterTable: change type "'.$change_name.'" not yet supported'); 'alterTable: change type "'.$change_name.'" not yet supported');
} }
} }
if ($check) {
return MDB2_OK;
}
$query = ''; $query = '';
if (!empty($changes['add']) && is_array($changes['add'])) { if (!empty($changes['add']) && is_array($changes['add'])) {
foreach ($changes['add'] as $field_name => $field) { foreach ($changes['add'] as $field_name => $field) {
if ($query) { if ($query) {
$query.= ', '; $query.= ', ';
} }
$query.= 'ADD ' . $db->getDeclaration($field['type'], $field_name, $field); $query.= 'ADD ' . $this->conn->getDeclaration($field['type'], $field_name, $field);
} }
} }
@ -182,7 +178,7 @@ class Doctrine_Export_Mssql extends Doctrine_Export {
if ($query) { if ($query) {
$query.= ', '; $query.= ', ';
} }
$field_name = $db->quoteIdentifier($field_name, true); $field_name = $this->conn->quoteIdentifier($field_name, true);
$query.= 'DROP COLUMN ' . $field_name; $query.= 'DROP COLUMN ' . $field_name;
} }
} }
@ -191,8 +187,8 @@ class Doctrine_Export_Mssql extends Doctrine_Export {
return MDB2_OK; return MDB2_OK;
} }
$name = $db->quoteIdentifier($name, true); $name = $this->conn->quoteIdentifier($name, true);
return $db->exec("ALTER TABLE $name $query"); return $this->conn->exec("ALTER TABLE $name $query");
} }
/** /**
* create sequence * create sequence
@ -235,6 +231,6 @@ class Doctrine_Export_Mssql extends Doctrine_Export {
*/ */
public function dropSequence($seqName) { public function dropSequence($seqName) {
$sequenceName = $db->quoteIdentifier($db->getSequenceName($seqName), true); $sequenceName = $db->quoteIdentifier($db->getSequenceName($seqName), true);
return $db->exec('DROP TABLE ' . $sequenceName); return $this->conn->exec('DROP TABLE ' . $sequenceName);
} }
} }

View File

@ -41,7 +41,7 @@ class Doctrine_Export_Mysql extends Doctrine_Export {
*/ */
public function createDatabase($name) { public function createDatabase($name) {
$query = 'CREATE DATABASE ' . $this->conn->quoteIdentifier($name, true); $query = 'CREATE DATABASE ' . $this->conn->quoteIdentifier($name, true);
$result = $this->conn->getDbh()->query($query); $result = $this->conn->exec($query);
} }
/** /**
* drop an existing database * drop an existing database
@ -52,7 +52,7 @@ class Doctrine_Export_Mysql extends Doctrine_Export {
*/ */
public function dropDatabase($name) { public function dropDatabase($name) {
$query = 'DROP DATABASE ' . $this->conn->quoteIdentifier($name); $query = 'DROP DATABASE ' . $this->conn->quoteIdentifier($name);
$this->conn->getDbh()->query($query); $this->conn->exec($query);
} }
/** /**
* create a new table * create a new table
@ -132,7 +132,7 @@ class Doctrine_Export_Mysql extends Doctrine_Export {
if (!empty($optionStrings)) { if (!empty($optionStrings)) {
$query.= ' '.implode(' ', $optionStrings); $query.= ' '.implode(' ', $optionStrings);
} }
return $this->conn->getDbh()->query($query); return $this->conn->exec($query);
} }
/** /**
* alter an existing table * alter an existing table
@ -392,7 +392,7 @@ class Doctrine_Export_Mysql extends Doctrine_Export {
} }
$query .= ' ('. implode(', ', $fields) . ')'; $query .= ' ('. implode(', ', $fields) . ')';
return $this->conn->getDbh()->query($query); return $this->conn->exec($query);
} }
/** /**
* drop existing index * drop existing index
@ -404,7 +404,7 @@ class Doctrine_Export_Mysql extends Doctrine_Export {
public function dropIndex($table, $name) { public function dropIndex($table, $name) {
$table = $this->conn->quoteIdentifier($table, true); $table = $this->conn->quoteIdentifier($table, true);
$name = $this->conn->quoteIdentifier($this->conn->getIndexName($name), true); $name = $this->conn->quoteIdentifier($this->conn->getIndexName($name), true);
return $this->conn->getDbh()->query('DROP INDEX ' . $name . ' ON ' . $table); return $this->conn->exec('DROP INDEX ' . $name . ' ON ' . $table);
} }
/** /**
* dropTable * dropTable
@ -415,7 +415,7 @@ class Doctrine_Export_Mysql extends Doctrine_Export {
*/ */
public function dropTable($table) { public function dropTable($table) {
$table = $this->conn->quoteIdentifier($table, true); $table = $this->conn->quoteIdentifier($table, true);
$this->conn->getDbh()->query('DROP TABLE ' . $table); $this->conn->exec('DROP TABLE ' . $table);
} }
} }
?> ?>

View File

@ -152,7 +152,7 @@ BEGIN
END IF; END IF;
END; END;
'; ';
return $this->conn->getDbh()->exec($trigger_sql); return $this->conn->exec($trigger_sql);
} }
/** /**
* drop an existing autoincrement sequence + trigger * drop an existing autoincrement sequence + trigger
@ -173,7 +173,7 @@ END;
$trigger_sql = 'DROP TRIGGER ' . $trigger_name; $trigger_sql = 'DROP TRIGGER ' . $trigger_name;
// if throws exception, trigger for autoincrement PK could not be dropped // if throws exception, trigger for autoincrement PK could not be dropped
$this->conn->getDbh()->exec($trigger_sql); $this->conn->exec($trigger_sql);
// if throws exception, sequence for autoincrement PK could not be dropped // if throws exception, sequence for autoincrement PK could not be dropped
$this->dropSequence($table); $this->dropSequence($table);
@ -417,7 +417,7 @@ END;
$sequenceName = $this->conn->quoteIdentifier($this->conn->getSequenceName($seqName), true); $sequenceName = $this->conn->quoteIdentifier($this->conn->getSequenceName($seqName), true);
$query = 'CREATE SEQUENCE ' . $sequenceName . ' START WITH ' . $start . ' INCREMENT BY 1 NOCACHE'; $query = 'CREATE SEQUENCE ' . $sequenceName . ' START WITH ' . $start . ' INCREMENT BY 1 NOCACHE';
$query.= ($start < 1 ? ' MINVALUE ' . $start : ''); $query.= ($start < 1 ? ' MINVALUE ' . $start : '');
return $this->conn->getDbh()->exec($query); return $this->conn->exec($query);
} }
/** /**
* drop existing sequence * drop existing sequence
@ -428,6 +428,6 @@ END;
*/ */
public function dropSequence($seqName) { public function dropSequence($seqName) {
$sequenceName = $this->conn->quoteIdentifier($this->conn->getSequenceName($seqName), true); $sequenceName = $this->conn->quoteIdentifier($this->conn->getSequenceName($seqName), true);
return $this->conn->getDbh()->exec('DROP SEQUENCE ' . $sequenceName); return $this->conn->exec('DROP SEQUENCE ' . $sequenceName);
} }
} }

View File

@ -41,7 +41,7 @@ class Doctrine_Export_Pgsql extends Doctrine_Export {
*/ */
public function createDatabase($name) { public function createDatabase($name) {
$query = 'CREATE DATABASE ' . $this->conn->quoteIdentifier($name); $query = 'CREATE DATABASE ' . $this->conn->quoteIdentifier($name);
$this->conn->getDbh()->query($query); $this->conn->exec($query);
} }
/** /**
* drop an existing database * drop an existing database
@ -52,7 +52,7 @@ class Doctrine_Export_Pgsql extends Doctrine_Export {
*/ */
public function dropDatabase($name) { public function dropDatabase($name) {
$query = 'DROP DATABASE ' . $this->conn->quoteIdentifier($name); $query = 'DROP DATABASE ' . $this->conn->quoteIdentifier($name);
$this->conn->getDbh()->query($query); $this->conn->exec($query);
} }
/** /**
* alter an existing table * alter an existing table

View File

@ -84,6 +84,6 @@ class Doctrine_Export_Sqlite extends Doctrine_Export {
$fields[] = $fieldString; $fields[] = $fieldString;
} }
$query .= ' ('.implode(', ', $fields) . ')'; $query .= ' ('.implode(', ', $fields) . ')';
return $this->conn->getDbh()->exec($query); return $this->conn->exec($query);
} }
} }

View File

@ -387,16 +387,29 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
} }
if ( !isset($this->tables[$key]) ) if ( !isset($this->tables[$key]) )
throw new Doctrine_Exception("No table named $key found."); throw new Doctrine_Exception('No table named ' . $key . ' found.');
$ids = $this->tables[$key]->getIdentifier(); $ids = $this->tables[$key]->getIdentifier();
$name = $key; $name = $key;
if($this->isIdentifiable($row, $ids)) { if($this->isIdentifiable($row, $ids)) {
if($name !== $root) {
$prev = $this->initRelated($prev, $name); $prev = $this->initRelated($prev, $name);
}
// aggregate values have numeric keys // aggregate values have numeric keys
if(isset($row[0])) { if(isset($row[0])) {
$component = $this->tables[$name]->getComponentName();
// if the collection already has objects, get the last object
// otherwise create a new one where the aggregate values are being mapped
if($prev[$name]->count() > 0) {
$record = $prev[$name]->getLast();
} else {
$record = new $component();
$prev[$name]->add($record);
}
$path = array_search($name, $this->tableAliases); $path = array_search($name, $this->tableAliases);
$alias = $this->getPathAlias($path); $alias = $this->getPathAlias($path);
@ -404,14 +417,16 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
foreach($row as $index => $value) { foreach($row as $index => $value) {
$agg = false; $agg = false;
if(isset($this->pendingAggregates[$alias][$index])) if(isset($this->pendingAggregates[$alias][$index])) {
$agg = $this->pendingAggregates[$alias][$index][3]; $agg = $this->pendingAggregates[$alias][$index][3];
$prev[$name]->setAggregateValue($agg, $value);
} }
$record->mapValue($agg, $value);
} }
}
continue; continue;
} }
@ -426,6 +441,21 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
// initialize a new record // initialize a new record
$record = $this->tables[$name]->getRecord(); $record = $this->tables[$name]->getRecord();
// aggregate values have numeric keys
if(isset($row[0])) {
$path = array_search($name, $this->tableAliases);
$alias = $this->getPathAlias($path);
// map each aggregate value
foreach($row as $index => $value) {
$agg = false;
if(isset($this->pendingAggregates[$alias][$index]))
$agg = $this->pendingAggregates[$alias][$index][3];
$record->mapValue($agg, $value);
}
}
if($name == $root) { if($name == $root) {
@ -462,7 +492,7 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
public function initRelated(array $prev, $name) { public function initRelated(array $prev, $name) {
$pointer = $this->joins[$name]; $pointer = $this->joins[$name];
$path = array_search($name, $this->tableAliases); $path = array_search($name, $this->tableAliases);
$tmp = explode(".", $path); $tmp = explode('.', $path);
$alias = end($tmp); $alias = end($tmp);
if( ! isset($prev[$pointer]) ) if( ! isset($prev[$pointer]) )

View File

@ -283,31 +283,40 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
* addFrom * addFrom
* *
* @param strint $from * @param strint $from
* @return Doctrine_Query
*/ */
public function addFrom($from) { public function addFrom($from) {
$class = 'Doctrine_Query_From'; $class = 'Doctrine_Query_From';
$parser = new $class($this); $parser = new $class($this);
$parser->parse($from); $parser->parse($from);
return $this;
} }
/** /**
* leftJoin * leftJoin
* *
* @param strint $join * @param strint $join
* @return Doctrine_Query
*/ */
public function leftJoin($join) { public function leftJoin($join) {
$class = 'Doctrine_Query_From'; $class = 'Doctrine_Query_From';
$parser = new $class($this); $parser = new $class($this);
$parser->parse('LEFT JOIN '. $join); $parser->parse('LEFT JOIN ' . $join);
return $this;
} }
/** /**
* innerJoin * innerJoin
* *
* @param strint $join * @param strint $join
* @return Doctrine_Query
*/ */
public function innerJoin($join) { public function innerJoin($join) {
$class = 'Doctrine_Query_From'; $class = 'Doctrine_Query_From';
$parser = new $class($this); $parser = new $class($this);
$parser->parse('INNER JOIN '. $join); $parser->parse('INNER JOIN ' . $join);
return $this;
} }
/** /**
* addWhere * addWhere

View File

@ -15,23 +15,36 @@ class Doctrine_Query_From extends Doctrine_Query_Part {
$parts = Doctrine_Query::bracketExplode($str, 'JOIN'); $parts = Doctrine_Query::bracketExplode($str, 'JOIN');
$operator = false; $operator = false;
switch(trim($parts[0])) {
case 'INNER':
$operator = ':';
case 'LEFT':
array_shift($parts);
}
$last = ''; $last = '';
foreach($parts as $k => $part) { foreach($parts as $k => $part) {
$part = trim($part); $part = trim($part);
$e = explode(" ", $part);
if(empty($part)) {
continue;
}
$e = explode(' ', $part);
if(end($e) == 'INNER' || end($e) == 'LEFT') if(end($e) == 'INNER' || end($e) == 'LEFT')
$last = array_pop($e); $last = array_pop($e);
$part = implode(" ", $e); $part = implode(' ', $e);
foreach(Doctrine_Query::bracketExplode($part, ',') as $reference) { foreach(Doctrine_Query::bracketExplode($part, ',') as $reference) {
$reference = trim($reference); $reference = trim($reference);
$e = explode('.', $reference); $e = explode('.', $reference);
if($operator) { if($operator) {
$reference = array_shift($e).$operator.implode('.', $e); $reference = array_shift($e) . $operator . implode('.', $e);
} }
$table = $this->query->load($reference); $table = $this->query->load($reference);
} }

View File

@ -74,24 +74,28 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* rather than the values of these protected variables * rather than the values of these protected variables
*/ */
/** /**
* @var object Doctrine_Table $table the factory that created this data access object * @var object Doctrine_Table $_table the factory that created this data access object
*/ */
protected $_table; protected $_table;
/** /**
* @var integer $id the primary keys of this object * @var integer $_id the primary keys of this object
*/ */
protected $_id = array(); protected $_id = array();
/** /**
* @var array $data the record data * @var array $_data the record data
*/ */
protected $_data = array(); protected $_data = array();
/** /**
* @var integer $state the state of this record * @var array $_values the values array, aggregate values and such are mapped into this array
*/
protected $_values = array();
/**
* @var integer $_state the state of this record
* @see STATE_* constants * @see STATE_* constants
*/ */
protected $_state; protected $_state;
/** /**
* @var array $modified an array containing properties that have been modified * @var array $_modified an array containing properties that have been modified
*/ */
protected $_modified = array(); protected $_modified = array();
/** /**
@ -723,6 +727,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
if($name === $this->_table->getIdentifier()) if($name === $this->_table->getIdentifier())
return null; return null;
if(isset($this->_values[$lower]))
return $this->_values[$lower];
$rel = $this->_table->getRelation($name); $rel = $this->_table->getRelation($name);
try { try {
@ -734,7 +741,20 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
return $this->references[$name]; return $this->references[$name];
} }
/**
* mapValue
* This simple method is used for mapping values to $values property.
* Usually this method is used internally by Doctrine for the mapping of
* aggregate values.
*
* @param string $name the name of the mapped value
* @param mixed $value mixed value to be mapped
* @return void
*/
public function mapValue($name, $value) {
$name = strtolower($name);
$this->_values[$name] = $value;
}
/** /**
* set * set
* method for altering properties and Doctrine_Record references * method for altering properties and Doctrine_Record references

View File

@ -242,7 +242,6 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
if($this->getAttribute(Doctrine::ATTR_CREATE_TABLES)) { if($this->getAttribute(Doctrine::ATTR_CREATE_TABLES)) {
if(Doctrine::isValidClassname($class->getName())) { if(Doctrine::isValidClassname($class->getName())) {
//$dict = new Doctrine_DataDict($this->getConnection()->getDBH());
try { try {
$columns = array(); $columns = array();
foreach($this->columns as $name => $column) { foreach($this->columns as $name => $column) {
@ -265,6 +264,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
} }
} }
} }
} else { } else {
throw new Doctrine_Table_Exception("Class '$name' has no table definition."); throw new Doctrine_Table_Exception("Class '$name' has no table definition.");

View File

@ -29,7 +29,6 @@ Building upon the above, we can say that the modifiers alter the field definitio
<br \><br \> <br \><br \>
Using the above example, we can also explore the default field operator. Default is set in the same way as the notnull operator to set a default value for the field. This value may be set in any character set that the DBMS supports for text fields, and any other valid data for the field's data type. In the above example, we have specified a valid time for the "Time" data type, '12:34:05'. Remember that when setting default dates and times, as well as datetimes, you should research and stay within the epoch of your chosen DBMS, otherwise you will encounter difficult to diagnose errors! Using the above example, we can also explore the default field operator. Default is set in the same way as the notnull operator to set a default value for the field. This value may be set in any character set that the DBMS supports for text fields, and any other valid data for the field's data type. In the above example, we have specified a valid time for the "Time" data type, '12:34:05'. Remember that when setting default dates and times, as well as datetimes, you should research and stay within the epoch of your chosen DBMS, otherwise you will encounter difficult to diagnose errors!
<br \><br \> <br \><br \>
Example 33-1. Example of the length modifier
<?php <?php
@ -44,5 +43,5 @@ Example 33-1. Example of the length modifier
<br \><br \> <br \><br \>
The above example will create a character varying field of length 12 characters in the database table. If the length definition is left out, MDB2 will create a length of the maximum allowable length for the data type specified, which may create a problem with some field types and indexing. Best practice is to define lengths for all or most of your fields. The above example will create a character varying field of length 12 characters in the database table. If the length definition is left out, Doctrine will create a length of the maximum allowable length for the data type specified, which may create a problem with some field types and indexing. Best practice is to define lengths for all or most of your fields.

View File

@ -141,6 +141,7 @@ $menu = array('Getting started' =>
'Enum', 'Enum',
'Gzip', 'Gzip',
), ),
/**
'Column attributes' => array( 'Column attributes' => array(
'Introduction', 'Introduction',
'Primary', 'Primary',
@ -170,7 +171,7 @@ $menu = array('Getting started' =>
'Autoincremented', 'Autoincremented',
'Natural', 'Natural',
'Composite', 'Composite',
'Sequential') 'Sequential')*/
), ),
'Basic Components' => 'Basic Components' =>

View File

@ -4,6 +4,7 @@ class AdapterMock implements Doctrine_Adapter_Interface {
private $queries = array(); private $queries = array();
private $exception = array();
public function __construct($name) { public function __construct($name) {
$this->name = $name; $this->name = $name;
@ -14,13 +15,25 @@ class AdapterMock implements Doctrine_Adapter_Interface {
public function pop() { public function pop() {
return array_pop($this->queries); return array_pop($this->queries);
} }
public function forceException($name, $message, $code) {
$this->exception = array($name, $message, $code);
}
public function prepare($prepareString){ public function prepare($prepareString){
return new AdapterStatementMock; return new AdapterStatementMock;
} }
public function query($queryString) { public function query($queryString) {
$this->queries[] = $queryString; $this->queries[] = $queryString;
$e = $this->exception;
if( ! empty($e)) {
$name = $e[0];
$this->exception = array();
throw new $name($e[1], $e[2]);
}
return new AdapterStatementMock; return new AdapterStatementMock;
} }
public function getAll() { public function getAll() {
@ -32,6 +45,16 @@ class AdapterMock implements Doctrine_Adapter_Interface {
public function exec($statement) { public function exec($statement) {
$this->queries[] = $statement; $this->queries[] = $statement;
$e = $this->exception;
if( ! empty($e)) {
$name = $e[0];
$this->exception = array();
throw new $name($e[1], $e[2]);
}
return 0; return 0;
} }
public function lastInsertId(){ } public function lastInsertId(){ }

View File

@ -3,6 +3,16 @@ class Doctrine_Export_Sqlite_TestCase extends Doctrine_Driver_UnitTestCase {
public function __construct() { public function __construct() {
parent::__construct('sqlite'); parent::__construct('sqlite');
} }
public function testExportDoesntWorkWithExistingTable() {
$this->manager->setAttribute(Doctrine::ATTR_CREATE_TABLES, false);
$this->adapter->forceException('PDOException', 'table already exist', 123);
$reporter = $this->export->export('User');
// Class name is not valid. Double underscores are not allowed
$this->assertEqual($reporter->pop(), array(E_ERROR, Doctrine::ERR_ALREADY_EXISTS));
}
public function testCreateDatabaseDoesNotExecuteSql() { public function testCreateDatabaseDoesNotExecuteSql() {
try { try {
$this->export->createDatabase('db'); $this->export->createDatabase('db');

View File

@ -1,6 +1,6 @@
<?php <?php
class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase { class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase {
public function prepareTables() { }
public function testAggregateFunctionWithDistinctKeyword() { public function testAggregateFunctionWithDistinctKeyword() {
$q = new Doctrine_Query(); $q = new Doctrine_Query();
@ -59,11 +59,12 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase {
$users = $q->execute(); $users = $q->execute();
$this->assertEqual($users[0]->Phonenumber->getAggregateValue('COUNT'), 1); $this->assertEqual($users[0]->Phonenumber[0]->COUNT, 1);
$this->assertEqual($users[1]->Phonenumber->getAggregateValue('COUNT'), 3); $this->assertEqual($users[1]->Phonenumber[0]->COUNT, 3);
$this->assertEqual($users[2]->Phonenumber->getAggregateValue('COUNT'), 1); $this->assertEqual($users[2]->Phonenumber[0]->COUNT, 1);
$this->assertEqual($users[3]->Phonenumber->getAggregateValue('COUNT'), 1); $this->assertEqual($users[3]->Phonenumber[0]->COUNT, 1);
$this->assertEqual($users[4]->Phonenumber->getAggregateValue('COUNT'), 3); $this->assertEqual($users[4]->Phonenumber[0]->COUNT, 3);
} }
public function testAggregateFunctionValueHydrationWithAliases() { public function testAggregateFunctionValueHydrationWithAliases() {
@ -74,13 +75,32 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase {
$users = $q->execute(); $users = $q->execute();
$this->assertEqual($users[0]->Phonenumber->getAggregateValue('count'), 1); $this->assertEqual($users[0]->Phonenumber[0]->count, 1);
$this->assertEqual($users[1]->Phonenumber->getAggregateValue('count'), 3); $this->assertEqual($users[1]->Phonenumber[0]->count, 3);
$this->assertEqual($users[2]->Phonenumber->getAggregateValue('count'), 1); $this->assertEqual($users[2]->Phonenumber[0]->count, 1);
$this->assertEqual($users[3]->Phonenumber->getAggregateValue('count'), 1); $this->assertEqual($users[3]->Phonenumber[0]->count, 1);
$this->assertEqual($users[4]->Phonenumber->getAggregateValue('count'), 3); $this->assertEqual($users[4]->Phonenumber[0]->count, 3);
} }
public function testMultipleAggregateFunctionValueHydrationWithAliases() { public function testMultipleAggregateFunctionValueHydrationWithAliases() {
$q = new Doctrine_Query();
$q->parseQuery('SELECT u.id, COUNT(p.id) count, MAX(p.phonenumber) max FROM User u, u.Phonenumber p GROUP BY u.id');
$users = $q->execute();
$this->assertEqual($users[0]->Phonenumber[0]->count, 1);
$this->assertEqual($users[1]->Phonenumber[0]->count, 3);
$this->assertEqual($users[2]->Phonenumber[0]->count, 1);
$this->assertEqual($users[3]->Phonenumber[0]->count, 1);
$this->assertEqual($users[4]->Phonenumber[0]->count, 3);
$this->assertEqual($users[0]->Phonenumber[0]->max, '123 123');
$this->assertEqual($users[1]->Phonenumber[0]->max, '789 789');
$this->assertEqual($users[2]->Phonenumber[0]->max, '123 123');
$this->assertEqual($users[3]->Phonenumber[0]->max, '111 222 333');
$this->assertEqual($users[4]->Phonenumber[0]->max, '444 555');
}
public function testMultipleAggregateFunctionValueHydrationWithAliasesAndCleanRecords() {
$this->connection->clear();
$q = new Doctrine_Query(); $q = new Doctrine_Query();
@ -88,18 +108,21 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase {
$users = $q->execute(); $users = $q->execute();
$this->assertEqual($users[0]->Phonenumber->getAggregateValue('count'), 1); $this->assertEqual($users[0]->Phonenumber[0]->state(), Doctrine_Record::STATE_TDIRTY);
$this->assertEqual($users[1]->Phonenumber->getAggregateValue('count'), 3);
$this->assertEqual($users[2]->Phonenumber->getAggregateValue('count'), 1);
$this->assertEqual($users[3]->Phonenumber->getAggregateValue('count'), 1);
$this->assertEqual($users[4]->Phonenumber->getAggregateValue('count'), 3);
$this->assertEqual($users[0]->Phonenumber->getAggregateValue('max'), '123 123'); $this->assertEqual($users[0]->Phonenumber[0]->count, 1);
$this->assertEqual($users[1]->Phonenumber->getAggregateValue('max'), '789 789'); $this->assertEqual($users[1]->Phonenumber[0]->count, 3);
$this->assertEqual($users[2]->Phonenumber->getAggregateValue('max'), '123 123'); $this->assertEqual($users[2]->Phonenumber[0]->count, 1);
$this->assertEqual($users[3]->Phonenumber->getAggregateValue('max'), '111 222 333'); $this->assertEqual($users[3]->Phonenumber[0]->count, 1);
$this->assertEqual($users[4]->Phonenumber->getAggregateValue('max'), '444 555'); $this->assertEqual($users[4]->Phonenumber[0]->count, 3);
$this->assertEqual($users[0]->Phonenumber[0]->max, '123 123');
$this->assertEqual($users[1]->Phonenumber[0]->max, '789 789');
$this->assertEqual($users[2]->Phonenumber[0]->max, '123 123');
$this->assertEqual($users[3]->Phonenumber[0]->max, '111 222 333');
$this->assertEqual($users[4]->Phonenumber[0]->max, '444 555');
} }
public function testSingleComponentWithAsterisk() { public function testSingleComponentWithAsterisk() {
$q = new Doctrine_Query(); $q = new Doctrine_Query();

View File

@ -5,13 +5,26 @@ class Doctrine_Query_Update_TestCase extends Doctrine_UnitTestCase {
$q->parseQuery("UPDATE User u SET u.name = 'someone'"); $q->parseQuery("UPDATE User u SET u.name = 'someone'");
$this->assertEqual($q->getQuery(), "UPDATE entity SET e.name = 'someone' WHERE (e.type = 0)"); $this->assertEqual($q->getQuery(), "UPDATE entity e SET e.name = 'someone' WHERE (e.type = 0)");
$q = new Doctrine_Query(); $q = new Doctrine_Query();
$q->update('User u')->set('u.name', 'someone'); $q->update('User u')->set('u.name', "'someone'");
$this->assertEqual($q->getQuery(), "UPDATE entity SET e.name = 'someone' WHERE (e.type = 0)"); $this->assertEqual($q->getQuery(), "UPDATE entity e SET e.name = 'someone' WHERE (e.type = 0)");
}
public function testUpdateWorksWithMultipleColumns() {
$q = new Doctrine_Query();
$q->parseQuery("UPDATE User u SET u.name = 'someone', u.email_id = 5");
$this->assertEqual($q->getQuery(), "UPDATE entity e SET e.name = 'someone', e.email_id = 5 WHERE (e.type = 0)");
$q = new Doctrine_Query();
$q->update('User u')->set('u.name', "'someone'")->set('u.email_id', 5);
$this->assertEqual($q->getQuery(), "UPDATE entity e SET e.name = 'someone', e.email_id = 5 WHERE (e.type = 0)");
} }
} }
?> ?>

View File

@ -44,6 +44,7 @@ require_once('QueryShortAliasesTestCase.php');
require_once('QueryDeleteTestCase.php'); require_once('QueryDeleteTestCase.php');
require_once('QueryUpdateTestCase.php'); require_once('QueryUpdateTestCase.php');
require_once('QueryIdentifierQuotingTestCase.php'); require_once('QueryIdentifierQuotingTestCase.php');
require_once('QueryAggregateValueTestCase.php');
require_once('UnitOfWorkTestCase.php'); require_once('UnitOfWorkTestCase.php');
@ -101,6 +102,7 @@ class Doctrine_Tester {
} }
*/ */
require_once('ExportTestCase.php'); require_once('ExportTestCase.php');
require_once('ExportReporterTestCase.php');
require_once('ExportMysqlTestCase.php'); require_once('ExportMysqlTestCase.php');
require_once('ExportFirebirdTestCase.php'); require_once('ExportFirebirdTestCase.php');
require_once('ExportPgsqlTestCase.php'); require_once('ExportPgsqlTestCase.php');
@ -147,9 +149,13 @@ $test->addTestCase(new Doctrine_Export_Firebird_TestCase());
$test->addTestCase(new Doctrine_Configurable_TestCase()); $test->addTestCase(new Doctrine_Configurable_TestCase());
$test->addTestCase(new Doctrine_Export_Sqlite_TestCase());
*/ */
$test->addTestCase(new Doctrine_Export_Reporter_TestCase());
$test->addTestCase(new Doctrine_Transaction_TestCase()); $test->addTestCase(new Doctrine_Transaction_TestCase());
@ -187,8 +193,6 @@ $test->addTestCase(new Doctrine_Query_MultiJoin_TestCase());
$test->addTestCase(new Doctrine_Record_TestCase()); $test->addTestCase(new Doctrine_Record_TestCase());
$test->addTestCase(new Doctrine_Relation_TestCase()); $test->addTestCase(new Doctrine_Relation_TestCase());
$test->addTestCase(new Doctrine_Record_State_TestCase()); $test->addTestCase(new Doctrine_Record_State_TestCase());
@ -197,7 +201,6 @@ $test->addTestCase(new Doctrine_Record_State_TestCase());
$test->addTestCase(new Doctrine_SchemaTestCase()); $test->addTestCase(new Doctrine_SchemaTestCase());
$test->addTestCase(new Doctrine_EventListenerTestCase()); $test->addTestCase(new Doctrine_EventListenerTestCase());
$test->addTestCase(new Doctrine_Connection_Transaction_TestCase()); $test->addTestCase(new Doctrine_Connection_Transaction_TestCase());
@ -210,10 +213,8 @@ $test->addTestCase(new Doctrine_BatchIteratorTestCase());
//$test->addTestCase(new Doctrine_Collection_Offset_TestCase()); //$test->addTestCase(new Doctrine_Collection_Offset_TestCase());
$test->addTestCase(new Doctrine_ViewTestCase()); $test->addTestCase(new Doctrine_ViewTestCase());
$test->addTestCase(new Doctrine_CustomPrimaryKeyTestCase()); $test->addTestCase(new Doctrine_CustomPrimaryKeyTestCase());
$test->addTestCase(new Doctrine_Filter_TestCase()); $test->addTestCase(new Doctrine_Filter_TestCase());
@ -232,7 +233,6 @@ $test->addTestCase(new Doctrine_RelationAccessTestCase());
$test->addTestCase(new Doctrine_CustomResultSetOrderTestCase()); $test->addTestCase(new Doctrine_CustomResultSetOrderTestCase());
//$test->addTestCase(new Doctrine_Record_Filter_TestCase()); //$test->addTestCase(new Doctrine_Record_Filter_TestCase());
$test->addTestCase(new Doctrine_Query_Condition_TestCase()); $test->addTestCase(new Doctrine_Query_Condition_TestCase());
@ -251,16 +251,18 @@ $test->addTestCase(new Doctrine_Query_From_TestCase());
$test->addTestCase(new Doctrine_Query_Delete_TestCase()); $test->addTestCase(new Doctrine_Query_Delete_TestCase());
$test->addTestCase(new Doctrine_Query_Update_TestCase());
$test->addTestCase(new Doctrine_Query_Where_TestCase()); $test->addTestCase(new Doctrine_Query_Where_TestCase());
$test->addTestCase(new Doctrine_Query_Limit_TestCase()); $test->addTestCase(new Doctrine_Query_Limit_TestCase());
$test->addTestCase(new Doctrine_Query_Select_TestCase());
$test->addTestCase(new Doctrine_Query_IdentifierQuoting_TestCase()); $test->addTestCase(new Doctrine_Query_IdentifierQuoting_TestCase());
$test->addTestCase(new Doctrine_Query_Update_TestCase());
$test->addTestCase(new Doctrine_Query_AggregateValue_TestCase());
$test->addTestCase(new Doctrine_Query_Select_TestCase());
//$test->addTestCase(new Doctrine_Cache_Query_SqliteTestCase()); //$test->addTestCase(new Doctrine_Cache_Query_SqliteTestCase());
//$test->addTestCase(new Doctrine_Cache_FileTestCase()); //$test->addTestCase(new Doctrine_Cache_FileTestCase());