1
0
mirror of synced 2025-02-21 14:43:14 +03:00

A little formatting and documentation.

This commit is contained in:
Jonathan.Wage 2007-10-20 02:30:15 +00:00
parent 526c4ab1c8
commit 8d2aebad70
9 changed files with 206 additions and 145 deletions

View File

@ -115,6 +115,7 @@ final class Doctrine
const PARAM_NULL = 0; const PARAM_NULL = 0;
const PARAM_STMT = 4; const PARAM_STMT = 4;
const PARAM_STR = 2; const PARAM_STR = 2;
/** /**
* ATTRIBUTE CONSTANTS * ATTRIBUTE CONSTANTS
*/ */
@ -180,7 +181,6 @@ final class Doctrine
const ATTR_RECORD_LISTENER = 154; const ATTR_RECORD_LISTENER = 154;
const ATTR_THROW_EXCEPTIONS = 155; const ATTR_THROW_EXCEPTIONS = 155;
/** /**
* LIMIT CONSTANTS * LIMIT CONSTANTS
*/ */
@ -189,7 +189,7 @@ final class Doctrine
* constant for row limiting * constant for row limiting
*/ */
const LIMIT_ROWS = 1; const LIMIT_ROWS = 1;
/** /**
* constant for record limiting * constant for record limiting
*/ */
@ -204,19 +204,19 @@ final class Doctrine
* mode for immediate fetching * mode for immediate fetching
*/ */
const FETCH_IMMEDIATE = 0; const FETCH_IMMEDIATE = 0;
/** /**
* BATCH FETCHING * BATCH FETCHING
* mode for batch fetching * mode for batch fetching
*/ */
const FETCH_BATCH = 1; const FETCH_BATCH = 1;
/** /**
* LAZY FETCHING * LAZY FETCHING
* mode for offset fetching * mode for offset fetching
*/ */
const FETCH_OFFSET = 3; const FETCH_OFFSET = 3;
/** /**
* LAZY OFFSET FETCHING * LAZY OFFSET FETCHING
* mode for lazy offset fetching * mode for lazy offset fetching
@ -232,7 +232,7 @@ final class Doctrine
* FETCH VALUEHOLDER * FETCH VALUEHOLDER
*/ */
const FETCH_VHOLDER = 1; const FETCH_VHOLDER = 1;
/** /**
* FETCH RECORD * FETCH RECORD
* *
@ -242,12 +242,12 @@ final class Doctrine
* This is the default fetchmode. * This is the default fetchmode.
*/ */
const FETCH_RECORD = 2; const FETCH_RECORD = 2;
/** /**
* FETCH ARRAY * FETCH ARRAY
*/ */
const FETCH_ARRAY = 3; const FETCH_ARRAY = 3;
/** /**
* PORTABILITY CONSTANTS * PORTABILITY CONSTANTS
*/ */
@ -257,7 +257,7 @@ final class Doctrine
* @see self::ATTR_PORTABILITY * @see self::ATTR_PORTABILITY
*/ */
const PORTABILITY_NONE = 0; const PORTABILITY_NONE = 0;
/** /**
* Portability: convert names of tables and fields to case defined in the * Portability: convert names of tables and fields to case defined in the
* "field_case" option when using the query*(), fetch*() methods. * "field_case" option when using the query*(), fetch*() methods.
@ -270,32 +270,32 @@ final class Doctrine
* @see self::ATTR_PORTABILITY * @see self::ATTR_PORTABILITY
*/ */
const PORTABILITY_RTRIM = 2; const PORTABILITY_RTRIM = 2;
/** /**
* Portability: force reporting the number of rows deleted. * Portability: force reporting the number of rows deleted.
* @see self::ATTR_PORTABILITY * @see self::ATTR_PORTABILITY
*/ */
const PORTABILITY_DELETE_COUNT = 4; const PORTABILITY_DELETE_COUNT = 4;
/** /**
* Portability: convert empty values to null strings in data output by * Portability: convert empty values to null strings in data output by
* query*() and fetch*(). * query*() and fetch*().
* @see self::ATTR_PORTABILITY * @see self::ATTR_PORTABILITY
*/ */
const PORTABILITY_EMPTY_TO_NULL = 8; const PORTABILITY_EMPTY_TO_NULL = 8;
/** /**
* Portability: removes database/table qualifiers from associative indexes * Portability: removes database/table qualifiers from associative indexes
* @see self::ATTR_PORTABILITY * @see self::ATTR_PORTABILITY
*/ */
const PORTABILITY_FIX_ASSOC_FIELD_NAMES = 16; const PORTABILITY_FIX_ASSOC_FIELD_NAMES = 16;
/** /**
* Portability: makes Doctrine_Expression throw exception for unportable RDBMS expressions * Portability: makes Doctrine_Expression throw exception for unportable RDBMS expressions
* @see self::ATTR_PORTABILITY * @see self::ATTR_PORTABILITY
*/ */
const PORTABILITY_EXPR = 32; const PORTABILITY_EXPR = 32;
/** /**
* Portability: turn on all portability features. * Portability: turn on all portability features.
* @see self::ATTR_PORTABILITY * @see self::ATTR_PORTABILITY
@ -310,46 +310,49 @@ final class Doctrine
* mode for optimistic locking * mode for optimistic locking
*/ */
const LOCK_OPTIMISTIC = 0; const LOCK_OPTIMISTIC = 0;
/** /**
* mode for pessimistic locking * mode for pessimistic locking
*/ */
const LOCK_PESSIMISTIC = 1; const LOCK_PESSIMISTIC = 1;
/** /**
* EXPORT CONSTANTS * EXPORT CONSTANTS
*/ */
/** /**
* turns of exporting * EXPORT_NONE
*/ */
const EXPORT_NONE = 0; const EXPORT_NONE = 0;
/** /**
* export tables * EXPORT_TABLES
*/ */
const EXPORT_TABLES = 1; const EXPORT_TABLES = 1;
/** /**
* export constraints * EXPORT_CONSTRAINTS
*/ */
const EXPORT_CONSTRAINTS = 2; const EXPORT_CONSTRAINTS = 2;
/** /**
* export plugins * EXPORT_PLUGINS
*/ */
const EXPORT_PLUGINS = 4; const EXPORT_PLUGINS = 4;
/** /**
* export all * EXPORT_ALL
*/ */
const EXPORT_ALL = 7; const EXPORT_ALL = 7;
/** /**
* HYDRATION CONSTANTS * HYDRATION CONSTANTS
*/ */
const HYDRATE_RECORD = 2; const HYDRATE_RECORD = 2;
/**
* HYDRATE_ARRAY
*/
const HYDRATE_ARRAY = 3; const HYDRATE_ARRAY = 3;
/** /**
@ -357,44 +360,70 @@ final class Doctrine
*/ */
const VALIDATE_NONE = 0; const VALIDATE_NONE = 0;
/**
* VALIDATE_LENGTHS
*/
const VALIDATE_LENGTHS = 1; const VALIDATE_LENGTHS = 1;
/**
* VALIDATE_TYPES
*/
const VALIDATE_TYPES = 2; const VALIDATE_TYPES = 2;
/**
* VALIDATE_CONSTRAINTS
*/
const VALIDATE_CONSTRAINTS = 4; const VALIDATE_CONSTRAINTS = 4;
/**
* VALIDATE_ALL
*/
const VALIDATE_ALL = 7; const VALIDATE_ALL = 7;
/** /**
* IDENTIFIER_AUTOINC
*
* constant for auto_increment identifier * constant for auto_increment identifier
*/ */
const IDENTIFIER_AUTOINC = 1; const IDENTIFIER_AUTOINC = 1;
/** /**
* IDENTIFIER_SEQUENCE
*
* constant for sequence identifier * constant for sequence identifier
*/ */
const IDENTIFIER_SEQUENCE = 2; const IDENTIFIER_SEQUENCE = 2;
/** /**
* IDENTIFIER_NATURAL
*
* constant for normal identifier * constant for normal identifier
*/ */
const IDENTIFIER_NATURAL = 3; const IDENTIFIER_NATURAL = 3;
/** /**
* IDENTIFIER_COMPOSITE
*
* constant for composite identifier * constant for composite identifier
*/ */
const IDENTIFIER_COMPOSITE = 4; const IDENTIFIER_COMPOSITE = 4;
/** /**
* Path
*
* @var string $path doctrine root directory * @var string $path doctrine root directory
*/ */
private static $_path; private static $_path;
/** /**
* Debug
*
* Bool true/false
*
* @var boolean $_debug * @var boolean $_debug
*/ */
private static $_debug = false; private static $_debug = false;
/** /**
* __construct * __construct
* *
@ -405,7 +434,7 @@ final class Doctrine
{ {
throw new Doctrine_Exception('Doctrine is static class. No instances can be created.'); throw new Doctrine_Exception('Doctrine is static class. No instances can be created.');
} }
/** /**
* debug * debug
* *
@ -420,7 +449,7 @@ final class Doctrine
return self::$_debug; return self::$_debug;
} }
/** /**
* getPath * getPath
* returns the doctrine root * returns the doctrine root
@ -435,7 +464,7 @@ final class Doctrine
return self::$_path; return self::$_path;
} }
/** /**
* loadAll * loadAll
* loads all runtime classes * loads all runtime classes
@ -446,7 +475,7 @@ final class Doctrine
{ {
return self::loadAllRuntimeClasses(); return self::loadAllRuntimeClasses();
} }
/** /**
* importSchema * importSchema
* method for importing existing schema to Doctrine_Record classes * method for importing existing schema to Doctrine_Record classes
@ -459,7 +488,7 @@ final class Doctrine
{ {
return self::generateModelsFromDb($directory, $databases); return self::generateModelsFromDb($directory, $databases);
} }
/** /**
* exportSchema * exportSchema
* method for exporting Doctrine_Record classes to a schema * method for exporting Doctrine_Record classes to a schema
@ -471,7 +500,7 @@ final class Doctrine
{ {
return self::createTablesFromModels($directory); return self::createTablesFromModels($directory);
} }
/** /**
* exportSql * exportSql
* method for exporting Doctrine_Record classes to a schema * method for exporting Doctrine_Record classes to a schema
@ -482,7 +511,7 @@ final class Doctrine
{ {
return self::generateSqlFromModels($directory); return self::generateSqlFromModels($directory);
} }
/** /**
* loadAllRuntimeClasses * loadAllRuntimeClasses
* *
@ -498,14 +527,14 @@ final class Doctrine
self::autoload($class); self::autoload($class);
} }
} }
/** /**
* loadModels * loadModels
* *
* Recursively load all models from a directory or array of directories * Recursively load all models from a directory or array of directories
* *
* @param string $directory Path to directory of models or array of directory paths * @param string $directory Path to directory of models or array of directory paths
* @return void * @return array $loadedModels
*/ */
public static function loadModels($directory) public static function loadModels($directory)
{ {
@ -529,14 +558,17 @@ final class Doctrine
return self::getLoadedModels($declared); return self::getLoadedModels($declared);
} }
/** /**
* getLoadedModels * getLoadedModels
* *
* Get all the loaded models, you can provide an array of classes or it will use get_declared_classes() * Get all the loaded models, you can provide an array of classes or it will use get_declared_classes()
* *
* Will filter through an array of classes and return the Doctrine_Records out of them.
* If you do not specify $classes it will return all of the currently loaded Doctrine_Records
*
* @param $classes Array of classes to filter through, otherwise uses get_declared_classes() * @param $classes Array of classes to filter through, otherwise uses get_declared_classes()
* @return void * @return array $loadedModels
*/ */
public static function getLoadedModels($classes = null) public static function getLoadedModels($classes = null)
{ {
@ -548,9 +580,7 @@ final class Doctrine
$loadedModels = array(); $loadedModels = array();
// we iterate trhough the diff of previously declared classes foreach ((array) $classes as $name) {
// and currently declared classes
foreach ($classes as $name) {
$class = new ReflectionClass($name); $class = new ReflectionClass($name);
// Skip the following classes // Skip the following classes
@ -568,14 +598,14 @@ final class Doctrine
return $loadedModels; return $loadedModels;
} }
/** /**
* getConnectionByTableName * getConnectionByTableName
* *
* Get the connection object for a table by the actual table name * Get the connection object for a table by the actual table name
* *
* @param string $tableName * @param string $tableName
* @return void * @return object Doctrine_Connection
*/ */
public static function getConnectionByTableName($tableName) public static function getConnectionByTableName($tableName)
{ {
@ -592,7 +622,7 @@ final class Doctrine
return Doctrine_Manager::connection(); return Doctrine_Manager::connection();
} }
/** /**
* generateModelsFromDb * generateModelsFromDb
* *
@ -601,12 +631,13 @@ final class Doctrine
* @param string $directory Directory to write your models to * @param string $directory Directory to write your models to
* @param array $databases Array of databases to generate models for * @param array $databases Array of databases to generate models for
* @return boolean * @return boolean
* @throws Exception
*/ */
public static function generateModelsFromDb($directory, array $databases = array()) public static function generateModelsFromDb($directory, array $databases = array())
{ {
return Doctrine_Manager::connection()->import->importSchema($directory, $databases); return Doctrine_Manager::connection()->import->importSchema($directory, $databases);
} }
/** /**
* generateYamlFromDb * generateYamlFromDb
* *
@ -630,6 +661,7 @@ final class Doctrine
return $result; return $result;
} }
/** /**
* generateModelsFromYaml * generateModelsFromYaml
* *
@ -646,7 +678,7 @@ final class Doctrine
return $import->importSchema($yamlPath, 'yml', $directory); return $import->importSchema($yamlPath, 'yml', $directory);
} }
/** /**
* createTablesFromModels * createTablesFromModels
* *
@ -659,12 +691,12 @@ final class Doctrine
{ {
return Doctrine_Manager::connection()->export->exportSchema($directory); return Doctrine_Manager::connection()->export->exportSchema($directory);
} }
/** /**
* generateSqlFromModels * generateSqlFromModels
* *
* @param string $directory * @param string $directory
* @return void * @return string $build String of sql queries. One query per line
*/ */
public static function generateSqlFromModels($directory = null) public static function generateSqlFromModels($directory = null)
{ {
@ -693,7 +725,7 @@ final class Doctrine
return $export->exportSchema($yamlPath, 'yml', $directory); return $export->exportSchema($yamlPath, 'yml', $directory);
} }
/** /**
* createDatabases * createDatabases
* *
@ -718,7 +750,7 @@ final class Doctrine
$connection->export->createDatabase($name); $connection->export->createDatabase($name);
} }
} }
/** /**
* dropDatabases * dropDatabases
* *
@ -743,7 +775,7 @@ final class Doctrine
$connection->export->dropDatabase($name); $connection->export->dropDatabase($name);
} }
} }
/** /**
* dumpData * dumpData
* *
@ -759,7 +791,7 @@ final class Doctrine
return $data->exportData($yamlPath, 'yml', array(), $individualFiles); return $data->exportData($yamlPath, 'yml', array(), $individualFiles);
} }
/** /**
* loadData * loadData
* *
@ -772,25 +804,15 @@ final class Doctrine
*/ */
public static function loadData($yamlPath, $append = false) public static function loadData($yamlPath, $append = false)
{ {
$delete = isset($append) ? ($append ? false : true) : true;
if ($delete)
{
$models = Doctrine::getLoadedModels();
foreach ($models as $model)
{
$model = new $model();
$model->getTable()->createQuery()->delete($model)->execute();
}
}
$data = new Doctrine_Data(); $data = new Doctrine_Data();
if (!$append) {
$data->purge();
}
return $data->importData($yamlPath, 'yml'); return $data->importData($yamlPath, 'yml');
} }
/** /**
* loadDummyData * loadDummyData
* *
@ -802,21 +824,11 @@ final class Doctrine
*/ */
public static function loadDummyData($append, $num = 5) public static function loadDummyData($append, $num = 5)
{ {
$delete = isset($append) ? ($append ? false : true) : true;
if ($delete)
{
$models = Doctrine::getLoadedModels();
foreach ($models as $model)
{
$model = new $model();
$model->getTable()->createQuery()->delete($model)->execute();
}
}
$data = new Doctrine_Data(); $data = new Doctrine_Data();
if (!$append) {
$data->purge();
}
return $data->importDummyData($num); return $data->importDummyData($num);
} }
@ -828,7 +840,8 @@ final class Doctrine
* *
* @param string $migrationsPath Path to migrations directory which contains your migration classes * @param string $migrationsPath Path to migrations directory which contains your migration classes
* @param string $to Version you wish to migrate to. * @param string $to Version you wish to migrate to.
* @return void * @return bool true
* @throws new Doctrine_Migration_Exception
*/ */
public static function migrate($migrationsPath, $to = null) public static function migrate($migrationsPath, $to = null)
{ {
@ -836,7 +849,7 @@ final class Doctrine
return $migration->migrate($to); return $migration->migrate($to);
} }
/** /**
* generateMigrationClass * generateMigrationClass
* *
@ -844,7 +857,6 @@ final class Doctrine
* *
* @param string $className Name of the Migration class to generate * @param string $className Name of the Migration class to generate
* @param string $migrationsPath Path to directory which contains your migration classes * @param string $migrationsPath Path to directory which contains your migration classes
* @package default
*/ */
public static function generateMigrationClass($className, $migrationsPath) public static function generateMigrationClass($className, $migrationsPath)
{ {
@ -852,12 +864,13 @@ final class Doctrine
return $builder->generateMigrationClass($className); return $builder->generateMigrationClass($className);
} }
/** /**
* generateMigrationsFromDb * generateMigrationsFromDb
* *
* @param string $migrationsPath * @param string $migrationsPath
* @return void * @return void
* @throws new Doctrine_Migration_Exception
*/ */
public static function generateMigrationsFromDb($migrationsPath) public static function generateMigrationsFromDb($migrationsPath)
{ {
@ -865,7 +878,7 @@ final class Doctrine
return $builder->generateMigrationsFromDb(); return $builder->generateMigrationsFromDb();
} }
/** /**
* generateMigrationsFromModels * generateMigrationsFromModels
* *
@ -903,6 +916,17 @@ final class Doctrine
return Doctrine_Manager::connection($adapter, $name); return Doctrine_Manager::connection($adapter, $name);
} }
/**
* fileFinder
*
* @param string $type
* @return void
*/
public static function fileFinder($type)
{
return Doctrine_FileFinder::type($type);
}
/** /**
* compile * compile
* method for making a single file of most used doctrine runtime components * method for making a single file of most used doctrine runtime components

View File

@ -1,6 +1,6 @@
<?php <?php
/* /*
* $Id: Task.php 2761 2007-10-07 23:42:29Z zYne $ * $Id: Cli.php 2761 2007-10-07 23:42:29Z zYne $
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@ -35,7 +35,7 @@ class Doctrine_Cli
protected $tasks = array(); protected $tasks = array();
protected $scriptName = null; protected $scriptName = null;
protected $config = array(); protected $config = array();
/** /**
* __construct * __construct
* *
@ -46,12 +46,13 @@ class Doctrine_Cli
{ {
$this->config = $config; $this->config = $config;
} }
/** /**
* run * run
* *
* @param string $args * @param string $args
* @return void * @return void
* @throws new Doctrine_Cli_Exception
*/ */
public function run($args) public function run($args)
{ {
@ -82,13 +83,13 @@ class Doctrine_Cli
throw new Doctrine_Cli_Exception('Cli task could not be found: '.$taskClass); throw new Doctrine_Cli_Exception('Cli task could not be found: '.$taskClass);
} }
} }
/** /**
* prepareArgs * prepareArgs
* *
* @param string $taskInstance * @param string $taskInstance
* @param string $args * @param string $args
* @return void * @return array $prepared
*/ */
protected function prepareArgs($taskInstance, $args) protected function prepareArgs($taskInstance, $args)
{ {
@ -128,10 +129,12 @@ class Doctrine_Cli
return $prepared; return $prepared;
} }
/** /**
* printTasks * printTasks
* *
* Prints an index of all the available tasks in the CLI instance
*
* @return void * @return void
*/ */
public function printTasks() public function printTasks()
@ -184,12 +187,12 @@ class Doctrine_Cli
echo "\n".str_repeat("-", 40)."\n"; echo "\n".str_repeat("-", 40)."\n";
} }
} }
/** /**
* loadTasks * loadTasks
* *
* @param string $directory * @param string $directory
* @return void * @return array $loadedTasks
*/ */
public function loadTasks($directory = null) public function loadTasks($directory = null)
{ {

View File

@ -238,7 +238,6 @@ class Doctrine_Data
* @param string $Doctrine_Record * @param string $Doctrine_Record
* @param string $fieldName * @param string $fieldName
* @return void * @return void
* @author Jonathan H. Wage
*/ */
public function isRelation(Doctrine_Record $record, $fieldName) public function isRelation(Doctrine_Record $record, $fieldName)
{ {
@ -255,4 +254,24 @@ class Doctrine_Data
return false; return false;
} }
/**
* purge
*
* Purge all data for loaded models or for the passed array of Doctrine_Records
*
* @param string $models
* @return void
*/
public function purge($models = array())
{
$models = Doctrine::getLoadedModels($models);
foreach ($models as $model)
{
$model = new $model();
$model->getTable()->createQuery()->delete($model)->execute();
}
}
} }

View File

@ -37,6 +37,7 @@ Doctrine::autoload('Doctrine_Connection_Module');
class Doctrine_Import extends Doctrine_Connection_Module class Doctrine_Import extends Doctrine_Connection_Module
{ {
protected $sql = array(); protected $sql = array();
/** /**
* lists all databases * lists all databases
* *
@ -50,6 +51,7 @@ class Doctrine_Import extends Doctrine_Connection_Module
return $this->conn->fetchColumn($this->sql['listDatabases']); return $this->conn->fetchColumn($this->sql['listDatabases']);
} }
/** /**
* lists all availible database functions * lists all availible database functions
* *
@ -63,6 +65,7 @@ class Doctrine_Import extends Doctrine_Connection_Module
return $this->conn->fetchColumn($this->sql['listFunctions']); return $this->conn->fetchColumn($this->sql['listFunctions']);
} }
/** /**
* lists all database triggers * lists all database triggers
* *
@ -73,6 +76,7 @@ class Doctrine_Import extends Doctrine_Connection_Module
{ {
throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.'); throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.');
} }
/** /**
* lists all database sequences * lists all database sequences
* *
@ -87,6 +91,7 @@ class Doctrine_Import extends Doctrine_Connection_Module
return $this->conn->fetchColumn($this->sql['listSequences']); return $this->conn->fetchColumn($this->sql['listSequences']);
} }
/** /**
* lists table constraints * lists table constraints
* *
@ -97,6 +102,7 @@ class Doctrine_Import extends Doctrine_Connection_Module
{ {
throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.'); throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.');
} }
/** /**
* lists table constraints * lists table constraints
* *
@ -107,6 +113,7 @@ class Doctrine_Import extends Doctrine_Connection_Module
{ {
throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.'); throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.');
} }
/** /**
* lists table constraints * lists table constraints
* *
@ -117,6 +124,7 @@ class Doctrine_Import extends Doctrine_Connection_Module
{ {
throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.'); throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.');
} }
/** /**
* lists tables * lists tables
* *
@ -127,6 +135,7 @@ class Doctrine_Import extends Doctrine_Connection_Module
{ {
throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.'); throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.');
} }
/** /**
* lists table triggers * lists table triggers
* *
@ -137,6 +146,7 @@ class Doctrine_Import extends Doctrine_Connection_Module
{ {
throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.'); throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.');
} }
/** /**
* lists table views * lists table views
* *
@ -147,6 +157,7 @@ class Doctrine_Import extends Doctrine_Connection_Module
{ {
throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.'); throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.');
} }
/** /**
* lists database users * lists database users
* *
@ -160,6 +171,7 @@ class Doctrine_Import extends Doctrine_Connection_Module
return $this->conn->fetchColumn($this->sql['listUsers']); return $this->conn->fetchColumn($this->sql['listUsers']);
} }
/** /**
* lists database views * lists database views
* *
@ -174,6 +186,7 @@ class Doctrine_Import extends Doctrine_Connection_Module
return $this->conn->fetchColumn($this->sql['listViews']); return $this->conn->fetchColumn($this->sql['listViews']);
} }
/** /**
* importSchema * importSchema
* *
@ -187,7 +200,13 @@ class Doctrine_Import extends Doctrine_Connection_Module
{ {
$connections = Doctrine_Manager::getInstance()->getConnections(); $connections = Doctrine_Manager::getInstance()->getConnections();
foreach ($connections as $connection) { foreach ($connections as $name => $connection) {
// Limit the databases to the ones specified by $databases.
// Check only happens if array is not empty
if (!empty($databases) && !in_array($name, $databases)) {
continue;
}
$builder = new Doctrine_Import_Builder(); $builder = new Doctrine_Import_Builder();
$builder->generateBaseClasses(true); $builder->generateBaseClasses(true);
$builder->setTargetPath($directory); $builder->setTargetPath($directory);

View File

@ -342,6 +342,8 @@ class Doctrine_Migration
} }
$this->setCurrentVersion($to); $this->setCurrentVersion($to);
return true;
} }
/** /**

View File

@ -41,7 +41,7 @@ class Doctrine_Migration_Builder
* @var string * @var string
*/ */
private $migrationsPath = ''; private $migrationsPath = '';
/** /**
* suffix * suffix
* *
@ -50,7 +50,7 @@ class Doctrine_Migration_Builder
* @var string $suffix * @var string $suffix
*/ */
private $suffix = '.class.php'; private $suffix = '.class.php';
/** /**
* tpl * tpl
* *
@ -73,7 +73,7 @@ class Doctrine_Migration_Builder
$this->loadTemplate(); $this->loadTemplate();
} }
/** /**
* setMigrationsPath * setMigrationsPath
* *
@ -130,7 +130,7 @@ class %s extends %s
} }
END; END;
} }
/** /**
* generateMigrationsFromDb * generateMigrationsFromDb
* *
@ -148,7 +148,7 @@ END;
return $result; return $result;
} }
/** /**
* generateMigrationsFromModels * generateMigrationsFromModels
* *
@ -194,6 +194,8 @@ END;
} }
$this->generateMigrationClass($className, array(), $up, $down); $this->generateMigrationClass($className, array(), $up, $down);
return true;
} }
/** /**
@ -243,7 +245,7 @@ END;
* buildDropTable * buildDropTable
* *
* @param string $tableData * @param string $tableData
* @return void * @return string
*/ */
public function buildDropTable($tableData) public function buildDropTable($tableData)
{ {
@ -254,7 +256,7 @@ END;
* dataToPhpCode * dataToPhpCode
* *
* @param string $data * @param string $data
* @return void * @return string
*/ */
public function dataToPhpCode($data) public function dataToPhpCode($data)
{ {
@ -269,7 +271,7 @@ END;
/** /**
* generateMigrationClass * generateMigrationClass
* *
* @package default * @return void
*/ */
public function generateMigrationClass($className, $options = array(), $up = null, $down = null, $return = false) public function generateMigrationClass($className, $options = array(), $up = null, $down = null, $return = false)
{ {
@ -296,7 +298,7 @@ END;
/** /**
* buildMigrationClass * buildMigrationClass
* *
* @package default * @return string
*/ */
public function buildMigrationClass($className, $fileName = null, $options = array(), $up = null, $down = null) public function buildMigrationClass($className, $fileName = null, $options = array(), $up = null, $down = null)
{ {

View File

@ -20,7 +20,9 @@
*/ */
/** /**
* Doctrine_Cli_Task * Doctrine_Task
*
* Abstract class used for writing Doctrine Tasks
* *
* @package Doctrine * @package Doctrine
* @subpackage Task * @subpackage Task
@ -41,6 +43,9 @@ abstract class Doctrine_Task
/** /**
* __construct * __construct
* *
* Since this is an abstract classes that extend this must follow a patter of Doctrine_Task_{TASK_NAME}
* This is what determines the task name for executing it.
*
* @return void * @return void
*/ */
public function __construct() public function __construct()
@ -54,7 +59,7 @@ abstract class Doctrine_Task
* Override with each task class * Override with each task class
* *
* @return void * @return void
* @author Jonathan H. Wage * @abstract
*/ */
abstract function execute(); abstract function execute();
@ -63,7 +68,7 @@ abstract class Doctrine_Task
* *
* Validates that all required fields are present * Validates that all required fields are present
* *
* @return void * @return bool true
*/ */
public function validate() public function validate()
{ {
@ -95,7 +100,7 @@ abstract class Doctrine_Task
* *
* @param string $name * @param string $name
* @param string $default * @param string $default
* @return void * @return mixed
*/ */
public function getArgument($name, $default = null) public function getArgument($name, $default = null)
{ {
@ -109,7 +114,7 @@ abstract class Doctrine_Task
/** /**
* getArguments * getArguments
* *
* @return void * @return array $this->arguments
*/ */
public function getArguments() public function getArguments()
{ {
@ -119,10 +124,10 @@ abstract class Doctrine_Task
/** /**
* setArguments * setArguments
* *
* @param string $args * @param array $args
* @return void * @return void
*/ */
public function setArguments($args) public function setArguments(array $args)
{ {
$this->arguments = $args; $this->arguments = $args;
} }
@ -130,7 +135,7 @@ abstract class Doctrine_Task
/** /**
* getTaskName * getTaskName
* *
* @return void * @return string $taskName
*/ */
public function getTaskName() public function getTaskName()
{ {
@ -140,7 +145,7 @@ abstract class Doctrine_Task
/** /**
* getDescription * getDescription
* *
* @return void * @return string $description
*/ */
public function getDescription() public function getDescription()
{ {
@ -150,7 +155,7 @@ abstract class Doctrine_Task
/** /**
* getRequiredArguments * getRequiredArguments
* *
* @return void * @return array $requiredArguments
*/ */
public function getRequiredArguments() public function getRequiredArguments()
{ {
@ -160,7 +165,7 @@ abstract class Doctrine_Task
/** /**
* getOptionalArguments * getOptionalArguments
* *
* @return void * @return array $optionalArguments
*/ */
public function getOptionalArguments() public function getOptionalArguments()
{ {
@ -170,7 +175,7 @@ abstract class Doctrine_Task
/** /**
* getRequiredArgumentsDescriptions * getRequiredArgumentsDescriptions
* *
* @return void * @return array $requiredArgumentsDescriptions
*/ */
public function getRequiredArgumentsDescriptions() public function getRequiredArgumentsDescriptions()
{ {
@ -180,8 +185,7 @@ abstract class Doctrine_Task
/** /**
* getOptionalArgumentsDescriptions * getOptionalArgumentsDescriptions
* *
* @return void * @return array $optionalArgumentsDescriptions
* @author Jonathan H. Wage
*/ */
public function getOptionalArgumentsDescriptions() public function getOptionalArgumentsDescriptions()
{ {

View File

@ -1,8 +1,4 @@
--- ---
Contact: Contact:
Contact_1: Contact_1:
name: Jonathan H. Wage name: Jonathan H. Wage
Contact_3:
name: Daniel Adams
Contact_4:
name: Robert Adams

View File

@ -1,14 +1,6 @@
--- ---
User: User:
User_1: User_1:
username: jwage username: jonwage
hair_color: light brown hair_color: brown
Contact: Contact_1 Contact: Contact_1
User_2:
username: dadams
hair_color: dark brown
Contact: Contact_3
User_3:
username: radams
hair_color: light brown
Contact: Contact_4