class Doctrine extends Doctrine_Core (View source)

This class only exists for backwards compatability. All code was moved to Doctrine_Core and this class extends Doctrine_Core

Constants

VERSION

VERSION

ERR

ERROR CONSTANTS

ERR_SYNTAX

ERR_CONSTRAINT

ERR_NOT_FOUND

ERR_ALREADY_EXISTS

ERR_UNSUPPORTED

ERR_MISMATCH

ERR_INVALID

ERR_NOT_CAPABLE

ERR_TRUNCATED

ERR_INVALID_NUMBER

ERR_INVALID_DATE

ERR_DIVZERO

ERR_NODBSELECTED

ERR_CANNOT_CREATE

ERR_CANNOT_DELETE

ERR_CANNOT_DROP

ERR_NOSUCHTABLE

ERR_NOSUCHFIELD

ERR_NEED_MORE_DATA

ERR_NOT_LOCKED

ERR_VALUE_COUNT_ON_ROW

ERR_INVALID_DSN

ERR_CONNECT_FAILED

ERR_EXTENSION_NOT_FOUND

ERR_NOSUCHDB

ERR_ACCESS_VIOLATION

ERR_CANNOT_REPLACE

ERR_CONSTRAINT_NOT_NULL

ERR_DEADLOCK

ERR_CANNOT_ALTER

ERR_MANAGER

ERR_MANAGER_PARSE

ERR_LOADMODULE

ERR_INSUFFICIENT_DATA

ERR_CLASS_NAME

CASE_LOWER

PDO derived constants

CASE_NATURAL

CASE_UPPER

CURSOR_FWDONLY

CURSOR_SCROLL

ERRMODE_EXCEPTION

ERRMODE_SILENT

ERRMODE_WARNING

FETCH_ASSOC

FETCH_BOTH

FETCH_BOUND

FETCH_CLASS

FETCH_CLASSTYPE

FETCH_COLUMN

FETCH_FUNC

FETCH_GROUP

FETCH_INTO

FETCH_LAZY

FETCH_NAMED

FETCH_NUM

FETCH_OBJ

FETCH_ORI_ABS

FETCH_ORI_FIRST

FETCH_ORI_LAST

FETCH_ORI_NEXT

FETCH_ORI_PRIOR

FETCH_ORI_REL

FETCH_SERIALIZE

FETCH_UNIQUE

NULL_EMPTY_STRING

NULL_NATURAL

NULL_TO_STRING

PARAM_BOOL

PARAM_INPUT_OUTPUT

PARAM_INT

PARAM_LOB

PARAM_NULL

PARAM_STMT

PARAM_STR

ATTR_AUTOCOMMIT

PDO derived attributes

ATTR_PREFETCH

ATTR_TIMEOUT

ATTR_ERRMODE

ATTR_SERVER_VERSION

ATTR_CLIENT_VERSION

ATTR_SERVER_INFO

ATTR_CONNECTION_STATUS

ATTR_CASE

ATTR_CURSOR_NAME

ATTR_CURSOR

ATTR_ORACLE_NULLS

ATTR_PERSISTENT

ATTR_STATEMENT_CLASS

ATTR_FETCH_TABLE_NAMES

ATTR_FETCH_CATALOG_NAMES

ATTR_DRIVER_NAME

ATTR_STRINGIFY_FETCHES

ATTR_MAX_COLUMN_LEN

ATTR_LISTENER

Doctrine constants

ATTR_QUOTE_IDENTIFIER

ATTR_FIELD_CASE

ATTR_IDXNAME_FORMAT

ATTR_SEQNAME_FORMAT

ATTR_SEQCOL_NAME

ATTR_CMPNAME_FORMAT

ATTR_DBNAME_FORMAT

ATTR_TBLCLASS_FORMAT

ATTR_TBLNAME_FORMAT

ATTR_FKNAME_FORMAT

ATTR_EXPORT

ATTR_DECIMAL_PLACES

ATTR_PORTABILITY

ATTR_VALIDATE

ATTR_COLL_KEY

ATTR_QUERY_LIMIT

ATTR_DEFAULT_TABLE_TYPE

ATTR_DEF_TEXT_LENGTH

ATTR_DEF_VARCHAR_LENGTH

ATTR_DEF_TABLESPACE

ATTR_EMULATE_DATABASE

ATTR_USE_NATIVE_ENUM

ATTR_DEFAULT_SEQUENCE

ATTR_FETCHMODE

ATTR_NAME_PREFIX

ATTR_CREATE_TABLES

ATTR_COLL_LIMIT

ATTR_CACHE

ATTR_RESULT_CACHE

ATTR_CACHE_LIFESPAN

ATTR_RESULT_CACHE_LIFESPAN

ATTR_LOAD_REFERENCES

ATTR_RECORD_LISTENER

ATTR_THROW_EXCEPTIONS

ATTR_DEFAULT_PARAM_NAMESPACE

ATTR_QUERY_CACHE

ATTR_QUERY_CACHE_LIFESPAN

ATTR_AUTOLOAD_TABLE_CLASSES

ATTR_MODEL_LOADING

ATTR_RECURSIVE_MERGE_FIXTURES

ATTR_USE_DQL_CALLBACKS

ATTR_AUTO_ACCESSOR_OVERRIDE

ATTR_AUTO_FREE_QUERY_OBJECTS

ATTR_DEFAULT_TABLE_CHARSET

ATTR_DEFAULT_TABLE_COLLATE

ATTR_DEFAULT_IDENTIFIER_OPTIONS

ATTR_DEFAULT_COLUMN_OPTIONS

ATTR_HYDRATE_OVERWRITE

ATTR_QUERY_CLASS

ATTR_CASCADE_SAVES

ATTR_COLLECTION_CLASS

ATTR_TABLE_CLASS

ATTR_USE_NATIVE_SET

ATTR_MODEL_CLASS_PREFIX

ATTR_TABLE_CLASS_FORMAT

ATTR_MAX_IDENTIFIER_LENGTH

LIMIT_ROWS

constant for row limiting

QUERY_LIMIT_ROWS

LIMIT_RECORDS

constant for record limiting

QUERY_LIMIT_RECORDS

PORTABILITY_NONE

Portability: turn off all portability features.

PORTABILITY_FIX_CASE

Portability: convert names of tables and fields to case defined in the "field_case" option when using the query(), fetch() methods.

PORTABILITY_RTRIM

Portability: right trim the data output by query() and fetch().

PORTABILITY_DELETE_COUNT

Portability: force reporting the number of rows deleted.

PORTABILITY_EMPTY_TO_NULL

Portability: convert empty values to null strings in data output by query() and fetch().

PORTABILITY_FIX_ASSOC_FIELD_NAMES

Portability: removes database/table qualifiers from associative indexes

PORTABILITY_EXPR

Portability: makes Doctrine_Expression throw exception for unportable RDBMS expressions

PORTABILITY_ALL

Portability: turn on all portability features.

LOCK_OPTIMISTIC

mode for optimistic locking

LOCK_PESSIMISTIC

mode for pessimistic locking

EXPORT_NONE

EXPORT_NONE

EXPORT_TABLES

EXPORT_TABLES

EXPORT_CONSTRAINTS

EXPORT_CONSTRAINTS

EXPORT_PLUGINS

EXPORT_PLUGINS

EXPORT_ALL

EXPORT_ALL

HYDRATE_RECORD

HYDRATE_RECORD

HYDRATE_ARRAY

HYDRATE_ARRAY

HYDRATE_NONE

HYDRATE_NONE

HYDRATE_SCALAR

HYDRATE_SCALAR

HYDRATE_SINGLE_SCALAR

HYDRATE_SINGLE_SCALAR

HYDRATE_ON_DEMAND

HYDRATE_ON_DEMAND

HYDRATE_ARRAY_HIERARCHY

HYDRATE_ARRAY_HIERARCHY

HYDRATE_RECORD_HIERARCHY

HYDRATE_RECORD_HIERARCHY

HYDRATE_ARRAY_SHALLOW

HYDRATE_ARRAY_SHALLOW

VALIDATE_NONE

VALIDATION CONSTANTS

VALIDATE_LENGTHS

VALIDATE_LENGTHS

VALIDATE_TYPES

VALIDATE_TYPES

VALIDATE_CONSTRAINTS

VALIDATE_CONSTRAINTS

VALIDATE_ALL

VALIDATE_ALL

VALIDATE_USER

VALIDATE_USER

IDENTIFIER_AUTOINC

IDENTIFIER_AUTOINC

constant for auto_increment identifier

IDENTIFIER_SEQUENCE

IDENTIFIER_SEQUENCE

constant for sequence identifier

IDENTIFIER_NATURAL

IDENTIFIER_NATURAL

constant for normal identifier

IDENTIFIER_COMPOSITE

IDENTIFIER_COMPOSITE

constant for composite identifier

MODEL_LOADING_AGGRESSIVE

MODEL_LOADING_AGGRESSIVE

Constant for agressive model loading Will require_once() all found model files

MODEL_LOADING_CONSERVATIVE

MODEL_LOADING_CONSERVATIVE

Constant for conservative model loading Will not require_once() found model files inititally instead it will build an array and reference it in autoload() when a class is needed it will require_once() it

MODEL_LOADING_PEAR

MODEL_LOADING_PEAR

Constant for pear model loading Will simply store the path passed to Doctrine_Core::loadModels() and Doctrine_Core::autoload() will check there

Methods

void
__construct()

__construct

static array
getLoadedModelFiles()

Returns an array of all the loaded models and the path where each of them exists

static void
debug(string $bool = null)

Turn on/off the debugging setting

static void
setPath(string $path)

Set the path to your core Doctrine libraries

static string
getPath()

Get the root path to Doctrine

static void
setExtensionsPath(string $extensionsPath)

Set the path to autoload extension classes from

static string
getExtensionsPath()

Get the path to load extension classes from

static null
loadModel($className, $path = null)

Load an individual model name and path in to the model loading registry

static void
setModelsDirectory(string $directory)

Set the directory where your models are located for PEAR style naming convention autoloading.

static void
getModelsDirectory()

Get the directory where your models are located for PEAR style naming convention autoloading

static 
loadModels(string $directory, integer $modelLoading = null, string $classPrefix = null)

Recursively load all models from a directory or array of directories

static array
getLoadedModels(classes $classes = null)

Get all the loaded models, you can provide an array of classes or it will use get_declared_classes()

static array
initializeModels(string $models)

Initialize all models so everything is present and loaded in to memory This will also inheritently initialize any model behaviors and add the models generated by Doctrine generators and add them to the $models array

static array
filterInvalidModels(classes $classes)

Filter through an array of classes and return all the classes that are valid models.

static boolean
isValidModelClass(mixed $class)

Checks if what is passed is a valid Doctrine_Record Will load class in to memory in order to inflect it and find out information about the class

getConnectionByTableName(string $tableName)

Get the connection object for a table by the actual table name FIXME: I think this method is flawed because a individual connections could have the same table name

static boolean
generateModelsFromDb(string $directory, array $connections = array(), array $options = array())

Method for importing existing schema to Doctrine_Record classes

static void
generateYamlFromDb(string $yamlPath, array $connections = array(), array $options = array())

Generates models from database to temporary location then uses those models to generate a yaml schema file.

static void
generateModelsFromYaml(string $yamlPath, string $directory, array $options = array())

Generate a yaml schema file from an existing directory of models

static void
createTablesFromModels(string $directory = null)

Creates database tables for the models in the specified directory

static void
createTablesFromArray(array $array)

Creates database tables for the models in the supplied array

static array
generateSqlFromArray(array $array)

Generate a array of sql for the passed array of models

static string
generateSqlFromModels(string $directory = null)

Generate a sql string to create the tables from all loaded models or the models found in the passed directory.

static void
generateYamlFromModels(string $yamlPath, string $directory)

Generate yaml schema file for the models in the specified directory

static void
createDatabases(string $specifiedConnections = array())

Creates databases for connections

static void
dropDatabases(string $specifiedConnections = array())

Drops databases for connections

static void
dumpData(string $yamlPath, string $individualFiles = false)

Dump data to a yaml fixtures file

static void
loadData(string $yamlPath, string $append = false)

Load data from a yaml fixtures file.

static bool
migrate(string $migrationsPath, string $to = null)

Migrate database to specified $to version. Migrates from current to latest if you do not specify.

static 
generateMigrationClass(string $className, string $migrationsPath)

Generate new migration class skeleton

static void
generateMigrationsFromDb(string $migrationsPath)

Generate a set of migration classes from an existing database

static void
generateMigrationsFromModels(string $migrationsPath, string $modelsPath = null, integer $modelLoading = null)

Generate a set of migration classes from an existing set of models

static array
generateMigrationsFromDiff(string $migrationsPath, string $from, string $to)

Generate a set of migration classes by generating differences between two sets of schema information

static Doctrine_Table
getTable(string $componentName)

Get the Doctrine_Table object for the passed model

static void
compile(string $target = null, array $includedDrivers = array())

Method for making a single file of most used doctrine runtime components including the compiled file instead of multiple files (in worst cases dozens of files) can improve performance by an order of magnitude

static boolean
autoload(string $className)

simple autoload function returns true if the class was loaded, otherwise false

static 
modelsAutoload($className)

No description

static boolean
extensionsAutoload(string $className)

Load classes from the Doctrine extensions directory/path

static void|string
dump(mixed $var, boolean $output = true, string $indent = "")

dumps a given variable

Details

void __construct()

__construct

Return Value

void

Exceptions

Doctrine_Exception

static array getLoadedModelFiles()

Returns an array of all the loaded models and the path where each of them exists

Return Value

array

static void debug(string $bool = null)

Turn on/off the debugging setting

Parameters

string $bool

Return Value

void

static void setPath(string $path)

Set the path to your core Doctrine libraries

Parameters

string $path The path to your Doctrine libraries

Return Value

void

static string getPath()

Get the root path to Doctrine

Return Value

string

static void setExtensionsPath(string $extensionsPath)

Set the path to autoload extension classes from

Parameters

string $extensionsPath

Return Value

void

static string getExtensionsPath()

Get the path to load extension classes from

Return Value

string $extensionsPath

static null loadModel($className, $path = null)

Load an individual model name and path in to the model loading registry

Parameters

$className
$path

Return Value

null

static void setModelsDirectory(string $directory)

Set the directory where your models are located for PEAR style naming convention autoloading.

Parameters

string $directory

Return Value

void

static void getModelsDirectory()

Get the directory where your models are located for PEAR style naming convention autoloading

Return Value

void

static loadModels(string $directory, integer $modelLoading = null, string $classPrefix = null)

Recursively load all models from a directory or array of directories

Parameters

string $directory Path to directory of models or array of directory paths
integer $modelLoading Pass value of Doctrine_Core::ATTR_MODEL_LOADING to force a certain style of model loading Allowed Doctrine_Core::MODEL_LOADING_AGGRESSIVE(default) or Doctrine_Core::MODEL_LOADING_CONSERVATIVE
string $classPrefix The class prefix of the models to load. This is useful if the class name and file name are not the same

static array getLoadedModels(classes $classes = null)

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

Parameters

classes $classes Array of classes to filter through, otherwise uses get_declared_classes()

Return Value

array $loadedModels

static array initializeModels(string $models)

Initialize all models so everything is present and loaded in to memory This will also inheritently initialize any model behaviors and add the models generated by Doctrine generators and add them to the $models array

Parameters

string $models

Return Value

array $models

static array filterInvalidModels(classes $classes)

Filter through an array of classes and return all the classes that are valid models.

This will inflect the class, causing it to be loaded in to memory.

Parameters

classes $classes Array of classes to filter through, otherwise uses get_declared_classes()

Return Value

array $loadedModels

static boolean isValidModelClass(mixed $class)

Checks if what is passed is a valid Doctrine_Record Will load class in to memory in order to inflect it and find out information about the class

Parameters

mixed $class Can be a string named after the class, an instance of the class, or an instance of the class reflected

Return Value

boolean

static Doctrine_Connection getConnectionByTableName(string $tableName)

Get the connection object for a table by the actual table name FIXME: I think this method is flawed because a individual connections could have the same table name

Parameters

string $tableName

Return Value

Doctrine_Connection

static boolean generateModelsFromDb(string $directory, array $connections = array(), array $options = array())

Method for importing existing schema to Doctrine_Record classes

Parameters

string $directory Directory to write your models to
array $connections Array of connection names to generate models for
array $options Array of options

Return Value

boolean

Exceptions

Exception

static void generateYamlFromDb(string $yamlPath, array $connections = array(), array $options = array())

Generates models from database to temporary location then uses those models to generate a yaml schema file.

This should probably be fixed. We should write something to generate a yaml schema file directly from the database.

Parameters

string $yamlPath Path to write oyur yaml schema file to
array $connections Array of connection names to generate yaml for
array $options Array of options

Return Value

void

static void generateModelsFromYaml(string $yamlPath, string $directory, array $options = array())

Generate a yaml schema file from an existing directory of models

Parameters

string $yamlPath Path to your yaml schema files
string $directory Directory to generate your models in
array $options Array of options to pass to the schema importer

Return Value

void

static void createTablesFromModels(string $directory = null)

Creates database tables for the models in the specified directory

Parameters

string $directory Directory containing your models

Return Value

void

static void createTablesFromArray(array $array)

Creates database tables for the models in the supplied array

Parameters

array $array An array of models to be exported

Return Value

void

static array generateSqlFromArray(array $array)

Generate a array of sql for the passed array of models

Parameters

array $array

Return Value

array $sql

static string generateSqlFromModels(string $directory = null)

Generate a sql string to create the tables from all loaded models or the models found in the passed directory.

Parameters

string $directory

Return Value

string $build String of sql queries. One query per line

static void generateYamlFromModels(string $yamlPath, string $directory)

Generate yaml schema file for the models in the specified directory

Parameters

string $yamlPath Path to your yaml schema files
string $directory Directory to generate your models in

Return Value

void

static void createDatabases(string $specifiedConnections = array())

Creates databases for connections

Parameters

string $specifiedConnections Array of connections you wish to create the database for

Return Value

void

static void dropDatabases(string $specifiedConnections = array())

Drops databases for connections

Parameters

string $specifiedConnections Array of connections you wish to drop the database for

Return Value

void

static void dumpData(string $yamlPath, string $individualFiles = false)

Dump data to a yaml fixtures file

Parameters

string $yamlPath Path to write the yaml data fixtures to
string $individualFiles Whether or not to dump data to individual fixtures files

Return Value

void

static void loadData(string $yamlPath, string $append = false)

Load data from a yaml fixtures file.

The output of dumpData can be fed to loadData

Parameters

string $yamlPath Path to your yaml data fixtures
string $append Whether or not to append the data

Return Value

void

static bool migrate(string $migrationsPath, string $to = null)

Migrate database to specified $to version. Migrates from current to latest if you do not specify.

Parameters

string $migrationsPath Path to migrations directory which contains your migration classes
string $to Version you wish to migrate to.

Return Value

bool true

Exceptions

new Doctrine_Migration_Exception

static generateMigrationClass(string $className, string $migrationsPath)

Generate new migration class skeleton

Parameters

string $className Name of the Migration class to generate
string $migrationsPath Path to directory which contains your migration classes

static void generateMigrationsFromDb(string $migrationsPath)

Generate a set of migration classes from an existing database

Parameters

string $migrationsPath

Return Value

void

Exceptions

new Doctrine_Migration_Exception

static void generateMigrationsFromModels(string $migrationsPath, string $modelsPath = null, integer $modelLoading = null)

Generate a set of migration classes from an existing set of models

Parameters

string $migrationsPath Path to your Doctrine migration classes
string $modelsPath Path to your Doctrine model classes
integer $modelLoading Style of model loading to use for loading the models in order to generate migrations

Return Value

void

static array generateMigrationsFromDiff(string $migrationsPath, string $from, string $to)

Generate a set of migration classes by generating differences between two sets of schema information

Parameters

string $migrationsPath Path to your Doctrine migration classes
string $from From schema information
string $to To schema information

Return Value

array $changes

static Doctrine_Table getTable(string $componentName)

Get the Doctrine_Table object for the passed model

Parameters

string $componentName

Return Value

Doctrine_Table

static void compile(string $target = null, array $includedDrivers = array())

Method for making a single file of most used doctrine runtime components including the compiled file instead of multiple files (in worst cases dozens of files) can improve performance by an order of magnitude

Parameters

string $target
array $includedDrivers

Return Value

void

Exceptions

Doctrine_Exception

static boolean autoload(string $className)

simple autoload function returns true if the class was loaded, otherwise false

Parameters

string $className

Return Value

boolean

static modelsAutoload($className)

Parameters

$className

static boolean extensionsAutoload(string $className)

Load classes from the Doctrine extensions directory/path

Parameters

string $className

Return Value

boolean

static void|string dump(mixed $var, boolean $output = true, string $indent = "")

dumps a given variable

Parameters

mixed $var a variable of any type
boolean $output whether to output the content
string $indent indention string

Return Value

void|string