Doctrine


Doctrine\Doctrine_Table
/Doctrine/Table.php at line 37

Class Doctrine_Table

Class:Doctrine_Table - Superclass: Doctrine_Configurable
Class:Doctrine_Configurable - Superclass: Doctrine_Locator_Injectable
Doctrine_Locator_Injectable
⌊ Doctrine_Configurable
⌊ Doctrine_Table

public class Doctrine_Table
extends Doctrine_Configurable

Doctrine_Table represents a database table each Doctrine_Table holds the information of foreignKeys and associations

Author:
Konsta Vesterinen
Package:
Doctrine
Subpackage:
Table
License:
http://www.opensource.org/licenses/lgpl-license.php LGPL
Version:
$Revision: 7681 $
See Also:
www.doctrine-project.org
Since:
1.0
Method:
mixed findBy*(mixed $value) magic finders; @see __call()
mixed findOneBy*(mixed $value) magic finders; @see __call()
Category:
Locator

Field Summary
protected array $_columnNames an array of column names keys are field names and values column names. used to look up column names from field names. this is the reverse lookup map of $_fieldNames.

$_columnNames

.

protected array $columns an array of column definitions, keys are column names and values are column definitions the definition array has atleast the following values: -- type the column type, eg. 'integer' -- length the column length, eg. 11 additional keys: -- notnull whether or not the column is marked as notnull -- values enum values -- notblank notblank validator + notnull constraint ... many more

$_columns

.

protected Doctrine_Connection $conn Doctrine_Connection object that created this table

$_conn

.

protected array $data temporary data which is then loaded into Doctrine_Record::$_data

$_data

.

protected array $_fieldNames an array of field names, used to look up field names from column names. Keys are column names and values are field names. Alias for columns are here.

$_fieldNames

.

protected array $_filters an array containing all record filters attached to this table

$_filters

.

protected Doctrine_Record_Generator $generator

$_generator

Generator instance responsible for constructing this table.

protected array $_generators an array containing all generators attached to this table

$_generators

.

protected mixed $identifier The field names of all fields that are part of the identifier/primary key

$_identifier

.

protected integer $identifierType the type of identifier this table uses

$_identifierType

.

protected array $identityMap first level cache

$_identityMap

.

protected array $_invokedMethods method invoker cache

$_invokedMethods

.

protected array $options an array containing all options -- name name of the component, for example component name of the GroupTable is 'Group' -- parents the parent classes of this component -- declaringClass name of the table definition declaring class (when using inheritance the class that defines the table structure can be any class in the inheritance hierarchy, hence we need reflection to check out which class actually calls setTableDefinition) -- tableName database table name, in most cases this is the same as component name but in some cases where one-table-multi-class inheritance is used this will be the name of the inherited table -- sequenceName Some databases need sequences instead of auto incrementation primary keys, you can set specific sequence for your table by calling setOption('sequenceName', $seqName) where $seqName is the name of the desired sequence -- enumMap enum value arrays -- inheritanceMap inheritanceMap is used for inheritance mapping, keys representing columns and values the column values that should correspond to child classes -- type table type (mysql example: INNODB) -- charset character set -- foreignKeys the foreign keys of this table -- checks the check constraints of this table, eg. 'price > dicounted_price' -- collate collate attribute -- indexes the index definitions of this table -- treeImpl the tree implementation of this table (if any) -- treeOptions the tree options -- queryParts the bound query parts -- versioning

$_options

.

protected Doctrine_Relation_Parser $_parser relation parser object

$_parser

.

protected Doctrine_Table_Repository $repository record repository

$_repository

.

protected array $_templates an array containing all templates attached to this table

$_templates

.

protected Doctrine_Tree $tree tree object associated with this table

$_tree

.

protected array $_uniques

$_uniques

Array of unique sets of fields.

protected integer $columnCount cached column count, Doctrine_Record uses this column count in when determining its state

$columnCount

.

protected boolean $hasDefaultValues whether or not this table has default values

$hasDefaultValues

.

protected Doctrine_Record $record empty instance of the given model

$record

.

Fields inherited from Doctrine\Doctrine_Configurable
_impl, _params, attributes, parent
Fields inherited from Doctrine\Doctrine_Locator_Injectable
_locator, _null, _resources
Constructor Summary

Doctrine_Table(string name, Doctrine_Connection conn, boolean initDefinition)

the constructor.

Method Summary
void

addCheckConstraint(mixed definition, mixed name, $definition )

Adds a check constraint to the table in-memory definition.

void

addForeignKey(array definition)

Adds a foreignKey to the table in-memory definition.

Doctrine_Table

addGenerator(Doctrine_Record_Generator generator, string name)

Adds a generate to the table instance..

void

addIndex(string index, array definition)

Adds an index to this table in-memory definition.

void

addNamedQuery(mixed queryKey, string|Doctrine_Query query)

Adds a named query in the query registry.

boolean

addRecord(Doctrine_Record record)

Adds a record to the first level cache (identity map).

Doctrine_Table

addTemplate(string template, Doctrine_Template impl)

Adds a template to this table..

final string

applyInheritance(mixed where, $where query)

applyInheritance.

Doctrine_Locator

bind(array args, integer type, string name, mixed resource, mixed value)

Adds a relation to the table.

Doctrine_Record

bindQueryPart(string queryPart, mixed value)

Adds default query parts to the selects executed on this table.

Doctrine_Table

bindQueryParts(array queryParts)

Binds query parts to this component..

void

buildFindByWhere(mixed fieldName)

void

clear()

Clears the first level cache (identityMap).

void

construct()

Construct template method.

integer

count()

Implements Countable interface..

Doctrine_Record

create(mixed array, $array an)

Creates a new record.

Doctrine_Query

createNamedQuery(string queryKey)

Creates a named query from one in the query registry.

Doctrine_Query

createQuery(string alias)

Creates a query on this table.

integer

enumIndex(string fieldName, mixed value)

Retrieves an enum index..

mixed

enumValue(string fieldName, integer index)

Retrieves an enum value.

Doctrine_Collection|array

execute(string queryKey, array params, int hydrationMode)

Finds result of a named query.

Doctrine_Record|array

executeOne(string queryKey, array params, int hydrationMode)

Fetches one record with a named query.

boolean

export()

Exports this table to database based on the schema definition.

mixed

find(mixed name, mixed params, int hydrationMode)

Finds a record by its identifier.

Doctrine_Collection|array

findAll(int hydrationMode)

Retrieves all the records stored in this table..

Doctrine_Collection|array

findBy(mixed fieldName, string value, int hydrationMode, string column)

Find records basing on a field..

Doctrine_Collection|array

findByDql(string dql, array params, int hydrationMode)

Finds records in this table with a given DQL where clause..

Doctrine_Collection|array

findBySql(string dql, array params, int hydrationMode)

Finds records in this table with a given SQL where clause..

Doctrine_Record

findOneBy(mixed fieldName, string value, int hydrationMode, string column)

Finds the first record that satisfy the clause..

string

getBoundQueryPart(string queryPart)

Retrieves a bound query part..

string

getClassnameToReturn()

Get the classname to return.

integer

getColumnCount()

.

array

getColumnDefinition(string columnName)

Retrieves a column definition from this table schema..

string

getColumnName(mixed fieldName, string alias)

Returns a column name for a column alias.

array

getColumnNames(mixed fieldNames)

Returns an array containing all the column names..

string

getColumnOwner(string columnName)

Gets the owner of a column.

array

getColumns()

Retrieves all columns of the table..

string

getComponentName()

Gets the subclass of Doctrine_Record that belongs to this table..

Doctrine_Connection|null

getConnection()

Returns the connection associated with this table (if any)..

array

getData()

Returns internal data.

mixed

getDefaultValueOf(string fieldName)

Retrieves the default value (if any) for a given column..

array

getDefinitionOf(string fieldName)

Retrieves the definition of a field.

array

getEnumValues(string fieldName)

Retrieves the enum values for a given field..

array

getExportableFormat(boolean parseForeignKeys)

Returns an exportable representation of this object.

integer

getFieldLength(string fieldName)

Gets the maximum length of a field.

string

getFieldName(string columnName)

Returns a column alias for a column name.

array

getFieldNames()

Returns an array containing all the field names..

array

getFieldValidators(string fieldName)

Gets the names of all validators being applied on a field..

array

getFilters()

getFilters.

Doctrine_Record_Generator

getGenerator(string generator)

Gets generator instance for a passed name..

array

getGenerators()

Gets all the generators for this table..

string

getIdentifier()

Returns the definition of the identifier key..

array

getIdentifierColumnNames()

Returns an array with all the identifier column names..

integer

getIdentifierType()

Retrieves the type of primary key.

array|boolean

getIndex(string index)

Retrieves an index definition.

void

getMethodOwner(string method)

getMethodOwner.

mixed

getOption(string name)

Returns the value of a given option..

array

getOptions()

Retrieves all options of this table and the associated values..

string

getOrderByStatement(string alias, boolean columnNames)

Get the table orderby statement.

Doctrine_Record_Generator

getParentGenerator()

Get the parent generator responsible for this table instance.

final Doctrine_Record

getProxy(mixed id, $id database)

.

Doctrine_Query

getQueryObject()

.

Doctrine_Record

getRecord()

Returns a new record.

Doctrine_Record

getRecordInstance()

Gets the record instance for this table.

Doctrine_Relation

getRelation(string alias, mixed recursive)

Retrieves a relation object for this component..

Doctrine_Relation_Parser

getRelationParser()

Retrieves the relation parser associated with this table..

array

getRelations()

Retrieves all relation objects defined on this table..

Doctrine_Table_Repository

getRepository()

Gets the internal record repository..

string

getTableName()

Gets the table name in the db..

Doctrine_Template

getTemplate(string template)

Retrieves a particular template by class name.

array

getTemplates()

Retrieves all templates (behaviors) attached to this table..

Doctrine_Tree

getTree()

Gets associated tree.

string

getTypeOf(string fieldName)

Retrieves the type of a field..

string

getTypeOfColumn(string columnName)

Retrieves the type of a column..

array

getUniques()

Gets the array of unique fields sets..

boolean

hasColumn(string columnName)

Finds out whether the table definition contains a given column..

boolean

hasDefaultValues()

Finds out whether this table has default values for columns..

boolean

hasField(string fieldName)

Finds out whether the table definition has a given field.

void

hasGenerator(string generator)

Checks if a generator name exists..

Doctrine_Record

hasMany(string componentName, string options)

Binds One-to-Many / Many-to-Many aggregate relation.

Doctrine_Record

hasOne(string componentName, string options)

Binds One-to-One aggregate relation.

boolean

hasRelation(string alias)

Tests if a relation exists.

boolean

hasTemplate(string template)

Checks if the table has a given template..

void

initDefinition(string name)

Initializes the in-memory table definition..

void

initIdentifier()

Initializes the primary key.

boolean

isGenerator()

Check whether this table was created by a record generator or not.

boolean

isIdentifier(string fieldName)

Checks whether a field is in the primary key.

boolean

isIdentifierAutoincrement()

Checks whether a field identifier is of type autoincrement.

boolean

isIdentifierComposite()

Checks whether a field identifier is a composite key..

boolean

isInheritedColumn(mixed columnName, $columnName The)

Checks whether a column is inherited from a component further up in the hierarchy..

boolean

isTree()

Determines if table acts as tree..

mixed

prepareValue(mixed fieldName, string value, string typeHint, string field)

Performs special data preparation.

string

processOrderBy(string alias, string orderBy, string columnNames)

Process an order by statement to be prefixed with the passed alias and field names converted to column names if the 3rd argument is true..

boolean

removeColumn(string fieldName)

Removes a field name from the table schema information..

boolean

removeRecord(Doctrine_Record record)

Removes a record from the identity map.

void

setColumn(string name, string type, integer length, mixed options, boolean prepend)

Adds a column to the schema.

void

setColumnOption(string columnName, string option, string value)

Set an individual column option.

void

setColumnOptions(string columnName, mixed options, array validators)

Customize the array of options for a column or multiple columns.

void

setColumns(array definitions)

Set multiple column definitions at once.

Doctrine_Table

setConnection(mixed conn)

Sets the default connection for this table.

void

setData(array data)

Doctrine uses this function internally.

void

setGenerator(Doctrine_Record_Generator generator)

Set the generator responsible for creating this table.

void

setMethodOwner(string method, string class)

setMethodOwner.

Doctrine_Table

setOption(string name, mixed value)

Sets an option for the table.

void

setOptions(array options)

Sets all the options.

void

setTableName(string tableName)

sets the table name in the schema definition..

void

unique(array fields, array options, bool createUniqueIndex)

Defines a n-uple of fields that must be unique for every record.

Doctrine_Table

unshiftFilter(Doctrine_Record_Filter filter)

unshiftFilter.

Doctrine_Validator_ErrorStack

validateField(string fieldName, string value, Doctrine_Record record)

Validates a given field using table ATTR_VALIDATE rules..

void

validateUniques(Doctrine_Record record)

Validates all the unique indexes.

Methods inherited from Doctrine\Doctrine_Configurable
addListener, addRecordListener, getAttribute, getAttributes, getCharset, getCollate, getImpl, getListener, getParam, getParamNamespaces, getParams, getParent, getRecordListener, hasImpl, setAttribute, setCharset, setCollate, setEventListener, setImpl, setListener, setParam, setParent, setRecordListener, unsetAttribute
Methods inherited from Doctrine\Doctrine_Locator_Injectable
bind, getLocator, getNullObject, initNullObject, locate, setLocator

Field Detail

/Doctrine/Table.php at line 109

_columnNames

protected array $_columnNames an array of column names keys are field names and values column names. used to look up column names from field names. this is the reverse lookup map of $_fieldNames. $_columnNames = array()


/Doctrine/Table.php at line 85

_columns

protected array $columns an array of column definitions, keys are column names and values are column definitions the definition array has atleast the following values: -- type the column type, eg. 'integer' -- length the column length, eg. 11 additional keys: -- notnull whether or not the column is marked as notnull -- values enum values -- notblank notblank validator + notnull constraint ... many more $_columns = array()


/Doctrine/Table.php at line 58

_conn

protected Doctrine_Connection $conn Doctrine_Connection object that created this table $_conn


/Doctrine/Table.php at line 42

_data

protected array $data temporary data which is then loaded into Doctrine_Record::$_data $_data = array()


/Doctrine/Table.php at line 100

_fieldNames

protected array $_fieldNames an array of field names, used to look up field names from column names. Keys are column names and values are field names. Alias for columns are here. $_fieldNames = array()


/Doctrine/Table.php at line 204

_filters

protected array $_filters an array containing all record filters attached to this table $_filters = array()

See Also:
Doctrine_Record_Filter

/Doctrine/Table.php at line 218

_generator

protected Doctrine_Record_Generator $generator $_generator

Generator instance responsible for constructing this table

See Also:
Doctrine_Record_Generator

/Doctrine/Table.php at line 210

_generators

protected array $_generators an array containing all generators attached to this table $_generators = array()

See Also:
Doctrine_Record_Generator

/Doctrine/Table.php at line 47

_identifier

protected mixed $identifier The field names of all fields that are part of the identifier/primary key $_identifier = array()


/Doctrine/Table.php at line 53

_identifierType

protected integer $identifierType the type of identifier this table uses $_identifierType

See Also:
constants

/Doctrine/Table.php at line 63

_identityMap

protected array $identityMap first level cache $_identityMap = array()


/Doctrine/Table.php at line 223

_invokedMethods

protected array $_invokedMethods method invoker cache $_invokedMethods = array()


/Doctrine/Table.php at line 165

_options

protected array $options an array containing all options -- name name of the component, for example component name of the GroupTable is 'Group' -- parents the parent classes of this component -- declaringClass name of the table definition declaring class (when using inheritance the class that defines the table structure can be any class in the inheritance hierarchy, hence we need reflection to check out which class actually calls setTableDefinition) -- tableName database table name, in most cases this is the same as component name but in some cases where one-table-multi-class inheritance is used this will be the name of the inherited table -- sequenceName Some databases need sequences instead of auto incrementation primary keys, you can set specific sequence for your table by calling setOption('sequenceName', $seqName) where $seqName is the name of the desired sequence -- enumMap enum value arrays -- inheritanceMap inheritanceMap is used for inheritance mapping, keys representing columns and values the column values that should correspond to child classes -- type table type (mysql example: INNODB) -- charset character set -- foreignKeys the foreign keys of this table -- checks the check constraints of this table, eg. 'price > dicounted_price' -- collate collate attribute -- indexes the index definitions of this table -- treeImpl the tree implementation of this table (if any) -- treeOptions the tree options -- queryParts the bound query parts -- versioning $_options = array(...)


/Doctrine/Table.php at line 192

_parser

protected Doctrine_Relation_Parser $_parser relation parser object $_parser


/Doctrine/Table.php at line 68

_repository

protected Doctrine_Table_Repository $repository record repository $_repository


/Doctrine/Table.php at line 198

_templates

protected array $_templates an array containing all templates attached to this table $_templates = array()

See Also:
Doctrine_Template

/Doctrine/Table.php at line 187

_tree

protected Doctrine_Tree $tree tree object associated with this table $_tree


/Doctrine/Table.php at line 92

_uniques

protected array $_uniques $_uniques = array()

Array of unique sets of fields. These values are validated on save


/Doctrine/Table.php at line 115

columnCount

protected integer $columnCount cached column count, Doctrine_Record uses this column count in when determining its state $columnCount


/Doctrine/Table.php at line 120

hasDefaultValues

protected boolean $hasDefaultValues whether or not this table has default values $hasDefaultValues


/Doctrine/Table.php at line 228

record

protected Doctrine_Record $record empty instance of the given model $record


Constructor Detail

/Doctrine/Table.php at line 238

Doctrine_Table

public Doctrine_Table(string name, Doctrine_Connection conn, boolean initDefinition)

the constructor

Throws:
if there are no opened connections
Parameters:
name - the name of the component
conn - the connection associated with this table
initDefinition - whether to init the in-memory schema

Method Detail

/Doctrine/Table.php at line 850

addCheckConstraint

public void addCheckConstraint(mixed definition, mixed name, $definition )

Adds a check constraint to the table in-memory definition.

This method adds a CHECK constraint to the schema definition. It does not add the constraint to the physical table in the db; @see export().

Parameters:
name - if string used as name for the constraint. Otherwise it is indexed numerically.

/Doctrine/Table.php at line 833

addForeignKey

public void addForeignKey(array definition)

Adds a foreignKey to the table in-memory definition.

This method adds a foreign key to the schema definition. It does not add the key to the physical table in the db; @see export().

Parameters:
definition - definition of the foreign key

/Doctrine/Table.php at line 2528

addGenerator

public Doctrine_Table addGenerator(Doctrine_Record_Generator generator, string name)

Adds a generate to the table instance.


/Doctrine/Table.php at line 871

addIndex

public void addIndex(string index, array definition)

Adds an index to this table in-memory definition.

This method adds an INDEX to the schema definition. It does not add the index to the physical table in the db; @see export().

Parameters:
index - index name
definition - keys are type, fields

/Doctrine/Table.php at line 1539

addNamedQuery

public void addNamedQuery(mixed queryKey, string|Doctrine_Query query)

Adds a named query in the query registry.

This methods register a query object with a name to use in the future.

See Also:
createNamedQuery()
Parameters:
query - key name to use for storage
query - DQL string or object

/Doctrine/Table.php at line 1773

addRecord

public boolean addRecord(Doctrine_Record record)

Adds a record to the first level cache (identity map).

This method is used internally to cache records, ensuring that only one object that represents a sql record exists in all scopes.

Parameters:
record - record to be added
Returns:
true if record was not present in the map
Todo:
Better name? registerRecord?

/Doctrine/Table.php at line 2478

addTemplate

public Doctrine_Table addTemplate(string template, Doctrine_Template impl)

Adds a template to this table.

Parameters:
template - template name
impl - behavior to attach

/Doctrine/Table.php at line 1935

applyInheritance

public final string applyInheritance(mixed where, $where query)

applyInheritance

Parameters:
query - where part to be modified
Returns:
query where part with column aggregation inheritance added

/Doctrine/Table.php at line 943

bind

public Doctrine_Locator bind(array args, integer type, string name, mixed resource, mixed value)

Adds a relation to the table.

This method defines a relation on this table, that will be present on every record belonging to this component.

Parameters:
args - first value is a string, name of related component; second value is array, options for the relation.
type - Doctrine_Relation::ONE or Doctrine_Relation::MANY
See Also:
Doctrine_Relation::_$definition
Todo:
Name proposal: addRelation

/Doctrine/Table.php at line 2593

bindQueryPart

public Doctrine_Record bindQueryPart(string queryPart, mixed value)

Adds default query parts to the selects executed on this table.

This method binds given value to given query part. Every query created by this table will have this part set by default.

Returns:
this object

/Doctrine/Table.php at line 2576

bindQueryParts

public Doctrine_Table bindQueryParts(array queryParts)

Binds query parts to this component.

See Also:
bindQueryPart()
Parameters:
queryParts - an array of pre-bound query parts
Returns:
this object

/Doctrine/Table.php at line 2726

buildFindByWhere

public void buildFindByWhere(mixed fieldName)

/Doctrine/Table.php at line 1758

clear

public void clear()

Clears the first level cache (identityMap).

This method ensures that records are reloaded from the db.

Todo:
what about a more descriptive name? clearIdentityMap?

/Doctrine/Table.php at line 287

construct

public void construct()

Construct template method.

This method provides concrete Table classes with the possibility to hook into the constructor procedure. It is called after the Doctrine_Table construction process is finished.


/Doctrine/Table.php at line 1953

count

public integer count()

Implements Countable interface.

Returns:
number of records in the table

/Doctrine/Table.php at line 1522

create

public Doctrine_Record create(mixed array, $array an)

Creates a new record.

This method create a new instance of the model defined by this table. The class of this record is the subclass of Doctrine_Record defined by this component. The record is not created in the database until you call @save().

Parameters:
an - array where keys are field names and values representing field values. Can contain also related components;
See Also:
Doctrine_Record::fromArray()
Returns:
the created record object

/Doctrine/Table.php at line 1554

createNamedQuery

public Doctrine_Query createNamedQuery(string queryKey)

Creates a named query from one in the query registry.

This method clones a new query object from a previously registered one.

See Also:
addNamedQuery()
Parameters:
queryKey - query key name

/Doctrine/Table.php at line 1028

createQuery

public Doctrine_Query createQuery(string alias)

Creates a query on this table.

This method returns a new Doctrine_Query object and adds the component name of this table as the query 'from' part. $table = Doctrine_Core::getTable('User'); $table->createQuery('myuser') ->where('myuser.Phonenumber = ?', '5551234');

Parameters:
alias - name for component aliasing

/Doctrine/Table.php at line 2017

enumIndex

public integer enumIndex(string fieldName, mixed value)

Retrieves an enum index.

See Also:
enumValue()
Parameters:
value - value of the enum considered
Returns:
can be string if native enums are used.

/Doctrine/Table.php at line 1994

enumValue

public mixed enumValue(string fieldName, integer index)

Retrieves an enum value.

This method finds a enum string value. If ATTR_USE_NATIVE_ENUM is set on the connection, index and value are the same thing.

Parameters:
index - numeric index of the enum

/Doctrine/Table.php at line 1728

execute

public Doctrine_Collection|array execute(string queryKey, array params, int hydrationMode)

Finds result of a named query.

This method fetches data using the provided $queryKey to choose a named query in the query registry.

Parameters:
queryKey - the query key
params - prepared statement params (if any)
hydrationMode - Doctrine_Core::HYDRATE_ARRAY or Doctrine_Core::HYDRATE_RECORD
Throws:
if no query for given queryKey is found

/Doctrine/Table.php at line 1745

executeOne

public Doctrine_Record|array executeOne(string queryKey, array params, int hydrationMode)

Fetches one record with a named query.

This method uses the provided $queryKey to clone and execute the associated named query in the query registry.

Parameters:
queryKey - the query key
params - prepared statement params (if any)
hydrationMode - Doctrine_Core::HYDRATE_ARRAY or Doctrine_Core::HYDRATE_RECORD
Throws:
if no query for given queryKey is found

/Doctrine/Table.php at line 635

export

public boolean export()

Exports this table to database based on the schema definition.

This method create a physical table in the database, using the definition that comes from the component Doctrine_Record instance.

Throws:
if some error other than Doctrine_Core::ERR_ALREADY_EXISTS occurred during the create table operation
Returns:
whether or not the export operation was successful false if table already existed in the database

/Doctrine/Table.php at line 1584

find

public mixed find(mixed name, mixed params, int hydrationMode)

Finds a record by its identifier.

$table->find(11); $table->find(11, Doctrine_Core::HYDRATE_RECORD); $table->find('namedQueryForYearArchive', array(2009), Doctrine_Core::HYDRATE_ARRAY);

Parameters:
name - Database Row ID or Query Name defined previously as a NamedQuery
params - This argument is the hydration mode (Doctrine_Core::HYDRATE_ARRAY or Doctrine_Core::HYDRATE_RECORD) if first param is a Database Row ID. Otherwise this argument expect an array of query params.
hydrationMode - Optional Doctrine_Core::HYDRATE_ARRAY or Doctrine_Core::HYDRATE_RECORD if first argument is a NamedQuery
Returns:
Doctrine_Collection, array, Doctrine_Record or false if no result

/Doctrine/Table.php at line 1646

findAll

public Doctrine_Collection|array findAll(int hydrationMode)

Retrieves all the records stored in this table.

Parameters:
hydrationMode - Doctrine_Core::HYDRATE_ARRAY or Doctrine_Core::HYDRATE_RECORD

/Doctrine/Table.php at line 1693

findBy

public Doctrine_Collection|array findBy(mixed fieldName, string value, int hydrationMode, string column)

Find records basing on a field.

Parameters:
column - field for the WHERE clause
value - prepared statement parameter
hydrationMode - Doctrine_Core::HYDRATE_ARRAY or Doctrine_Core::HYDRATE_RECORD

/Doctrine/Table.php at line 1677

findByDql

public Doctrine_Collection|array findByDql(string dql, array params, int hydrationMode)

Finds records in this table with a given DQL where clause.

Parameters:
dql - DQL WHERE clause
params - preparated statement parameters
hydrationMode - Doctrine_Core::HYDRATE_ARRAY or Doctrine_Core::HYDRATE_RECORD

/Doctrine/Table.php at line 1663

findBySql

public Doctrine_Collection|array findBySql(string dql, array params, int hydrationMode)

Finds records in this table with a given SQL where clause.

Parameters:
dql - DQL WHERE clause to use
params - query parameters (a la PDO)
hydrationMode - Doctrine_Core::HYDRATE_ARRAY or Doctrine_Core::HYDRATE_RECORD
Todo:
This actually takes DQL, not SQL, but it requires column names instead of field names. This should be fixed to use raw SQL instead.

/Doctrine/Table.php at line 1708

findOneBy

public Doctrine_Record findOneBy(mixed fieldName, string value, int hydrationMode, string column)

Finds the first record that satisfy the clause.

Parameters:
column - field for the WHERE clause
value - prepared statement parameter
hydrationMode - Doctrine_Core::HYDRATE_ARRAY or Doctrine_Core::HYDRATE_RECORD

/Doctrine/Table.php at line 2665

getBoundQueryPart

public string getBoundQueryPart(string queryPart)

Retrieves a bound query part.

See Also:
bindQueryPart()
Parameters:
queryPart - field interested
Returns:
value of the bind

/Doctrine/Table.php at line 1884

getClassnameToReturn

public string getClassnameToReturn()

Get the classname to return. Most often this is just the options['name'].

Check the subclasses option and the inheritanceMap for each subclass to see if all the maps in a subclass is met. If this is the case return that subclass name. If no subclasses match or if there are no subclasses defined return the name of the class for this tables record.

Todo:
this function could use reflection to check the first time it runs if the subclassing option is not set.
Returns:
The name of the class to create
Deprecated.

/Doctrine/Table.php at line 2147

getColumnCount

public integer getColumnCount()

Returns:
the number of columns in this table

/Doctrine/Table.php at line 1176

getColumnDefinition

public array getColumnDefinition(string columnName)

Retrieves a column definition from this table schema.

Returns:
column definition; @see $_columns

/Doctrine/Table.php at line 1157

getColumnName

public string getColumnName(mixed fieldName, string alias)

Returns a column name for a column alias.

If the actual name for the alias cannot be found this method returns the given alias.

Parameters:
alias - column alias
Returns:
column name

/Doctrine/Table.php at line 2187

getColumnNames

public array getColumnNames(mixed fieldNames)

Returns an array containing all the column names.

Returns:
numeric array

/Doctrine/Table.php at line 523

getColumnOwner

public string getColumnOwner(string columnName)

Gets the owner of a column.

The owner of a column is the name of the component in a hierarchy that defines the column.

Parameters:
columnName - the column name
Returns:
the name of the owning/defining component

/Doctrine/Table.php at line 2158

getColumns

public array getColumns()

Retrieves all columns of the table.

See Also:
$_columns;
Returns:
keys are column names and values are definition

/Doctrine/Table.php at line 2392

getComponentName

public string getComponentName()

Gets the subclass of Doctrine_Record that belongs to this table.


/Doctrine/Table.php at line 1503

getConnection

public Doctrine_Connection|null getConnection()

Returns the connection associated with this table (if any).

Returns:
the connection object

/Doctrine/Table.php at line 2289

getData

public array getData()

Returns internal data.

This method is used by Doctrine_Record instances when retrieving data from database.


/Doctrine/Table.php at line 1423

getDefaultValueOf

public mixed getDefaultValueOf(string fieldName)

Retrieves the default value (if any) for a given column.

Parameters:
fieldName - column name
Returns:
default value as set in definition

/Doctrine/Table.php at line 2240

getDefinitionOf

public array getDefinitionOf(string fieldName)

Retrieves the definition of a field.

This method retrieves the definition of the column, basing of $fieldName which can be a column name or a field name (alias).

Returns:
false on failure

/Doctrine/Table.php at line 1974

getEnumValues

public array getEnumValues(string fieldName)

Retrieves the enum values for a given field.


/Doctrine/Table.php at line 650

getExportableFormat

public array getExportableFormat(boolean parseForeignKeys)

Returns an exportable representation of this object.

This method produces a array representation of the table schema, where keys are tableName, columns (@see $_columns) and options. The options subarray contains 'primary' and 'foreignKeys'.

Parameters:
parseForeignKeys - whether to include foreign keys definition in the options

/Doctrine/Table.php at line 2653

getFieldLength

public integer getFieldLength(string fieldName)

Gets the maximum length of a field. For integer fields, length is bytes occupied. For decimal fields, it is the total number of cyphers


/Doctrine/Table.php at line 1192

getFieldName

public string getFieldName(string columnName)

Returns a column alias for a column name.

If no alias can be found the column name is returned.

Parameters:
columnName - column name
Returns:
column alias

/Doctrine/Table.php at line 2226

getFieldNames

public array getFieldNames()

Returns an array containing all the field names.

Returns:
numeric array

/Doctrine/Table.php at line 2606

getFieldValidators

public array getFieldValidators(string fieldName)

Gets the names of all validators being applied on a field.

Returns:
names of validators

/Doctrine/Table.php at line 2696

getFilters

public array getFilters()

getFilters

Returns:
$filters

/Doctrine/Table.php at line 2501

getGenerator

public Doctrine_Record_Generator getGenerator(string generator)

Gets generator instance for a passed name.

Returns:
$generator

/Doctrine/Table.php at line 2490

getGenerators

public array getGenerators()

Gets all the generators for this table.

Returns:
$generators

/Doctrine/Table.php at line 1440

getIdentifier

public string getIdentifier()

Returns the definition of the identifier key.

Returns:
can be array if a multi-column primary key is used.

/Doctrine/Table.php at line 2205

getIdentifierColumnNames

public array getIdentifierColumnNames()

Returns an array with all the identifier column names.

Returns:
numeric array

/Doctrine/Table.php at line 1452

getIdentifierType

public integer getIdentifierType()

Retrieves the type of primary key.

This method finds out if the primary key is multifield.

See Also:
constants

/Doctrine/Table.php at line 898

getIndex

public array|boolean getIndex(string index)

Retrieves an index definition.

This method returns a given index definition: @see addIndex().

Parameters:
index - index name; @see addIndex()
Returns:
array on success, FALSE on failure

/Doctrine/Table.php at line 607

getMethodOwner

public void getMethodOwner(string method)

getMethodOwner


/Doctrine/Table.php at line 1086

getOption

public mixed getOption(string name)

Returns the value of a given option.

See Also:
for available options
Parameters:
name - the name of the option
Returns:
the value of given option

/Doctrine/Table.php at line 803

getOptions

public array getOptions()

Retrieves all options of this table and the associated values.

Returns:
all options and their values

/Doctrine/Table.php at line 1102

getOrderByStatement

public string getOrderByStatement(string alias, boolean columnNames)

Get the table orderby statement

Parameters:
alias - The alias to use
columnNames - Whether or not to use column names instead of field names
Returns:
$orderByStatement

/Doctrine/Table.php at line 2564

getParentGenerator

public Doctrine_Record_Generator getParentGenerator()

Get the parent generator responsible for this table instance


/Doctrine/Table.php at line 1911

getProxy

public final Doctrine_Record getProxy(mixed id, $id database)

Parameters:
database - row id
Throws:
Doctrine_Find_Exception

/Doctrine/Table.php at line 1961

getQueryObject

public Doctrine_Query getQueryObject()

Returns:
a Doctrine_Query object

/Doctrine/Table.php at line 1816

getRecord

public Doctrine_Record getRecord()

Returns a new record.

This method checks if a internal record exists in identityMap, if does not exist it creates a new one.


/Doctrine/Table.php at line 542

getRecordInstance

public Doctrine_Record getRecordInstance()

Gets the record instance for this table.

The Doctrine_Table instance always holds at least one instance of a model so that it can be reused for several things, but primarily it is first used to instantiate all the internal in memory schema definition.

Returns:
Empty instance of the record

/Doctrine/Table.php at line 999

getRelation

public Doctrine_Relation getRelation(string alias, mixed recursive)

Retrieves a relation object for this component.

Parameters:
alias - relation alias; @see hasRelation()

/Doctrine/Table.php at line 755

getRelationParser

public Doctrine_Relation_Parser getRelationParser()

Retrieves the relation parser associated with this table.

Returns:
relation parser object

/Doctrine/Table.php at line 1009

getRelations

public array getRelations()

Retrieves all relation objects defined on this table.


/Doctrine/Table.php at line 1045

getRepository

public Doctrine_Table_Repository getRepository()

Gets the internal record repository.


/Doctrine/Table.php at line 2402

getTableName

public string getTableName()

Gets the table name in the db.


/Doctrine/Table.php at line 2449

getTemplate

public Doctrine_Template getTemplate(string template)

Retrieves a particular template by class name.

This method retrieves a behavior/template object attached to the table. For Doctrine_Template_* classes, the base name can be used.

Parameters:
template - name of the behavior
Throws:
if the given template is not set on this table

/Doctrine/Table.php at line 2433

getTemplates

public array getTemplates()

Retrieves all templates (behaviors) attached to this table.

Returns:
an array containing all templates

/Doctrine/Table.php at line 2372

getTree

public Doctrine_Tree getTree()

Gets associated tree. This method returns the associated Tree object (if any exists). Normally implemented by NestedSet behavior.

Returns:
false if not a tree

/Doctrine/Table.php at line 2252

getTypeOf

public string getTypeOf(string fieldName)

Retrieves the type of a field.

Returns:
false on failure

/Doctrine/Table.php at line 2263

getTypeOfColumn

public string getTypeOfColumn(string columnName)

Retrieves the type of a column.

Returns:
false if column is not found

/Doctrine/Table.php at line 2216

getUniques

public array getUniques()

Gets the array of unique fields sets.

See Also:
$_uniques;
Returns:
numeric array

/Doctrine/Table.php at line 1462

hasColumn

public boolean hasColumn(string columnName)

Finds out whether the table definition contains a given column.


/Doctrine/Table.php at line 1412

hasDefaultValues

public boolean hasDefaultValues()

Finds out whether this table has default values for columns.


/Doctrine/Table.php at line 1475

hasField

public boolean hasField(string fieldName)

Finds out whether the table definition has a given field.

This method returns true if @see hasColumn() returns true or if an alias named $fieldName exists.


/Doctrine/Table.php at line 2516

hasGenerator

public void hasGenerator(string generator)

Checks if a generator name exists.


/Doctrine/Table.php at line 972

hasMany

public Doctrine_Record hasMany(string componentName, string options)

Binds One-to-Many / Many-to-Many aggregate relation

Parameters:
componentName - the name of the related component
options - relation options
See Also:
Doctrine_Relation::_$definition
Returns:
this object

/Doctrine/Table.php at line 959

hasOne

public Doctrine_Record hasOne(string componentName, string options)

Binds One-to-One aggregate relation

Parameters:
componentName - the name of the related component
options - relation options
See Also:
Doctrine_Relation::_$definition
Returns:
this object

/Doctrine/Table.php at line 988

hasRelation

public boolean hasRelation(string alias)

Tests if a relation exists.

This method queries the table definition to find out if a relation is defined for this component. Alias defined with foreignAlias are not recognized as there's only one Doctrine_Relation object on the owning side.

Parameters:
alias - the relation alias to search for.
Returns:
true if the relation exists. Otherwise false.

/Doctrine/Table.php at line 2466

hasTemplate

public boolean hasTemplate(string template)

Checks if the table has a given template.

Parameters:
template - name of template; @see getTemplate()

/Doctrine/Table.php at line 295

initDefinition

public void initDefinition(string name)

Initializes the in-memory table definition.


/Doctrine/Table.php at line 412

initIdentifier

public void initIdentifier()

Initializes the primary key.

Called in the construction process, builds the identifier definition copying in the schema the list of the fields which constitutes the primary key.


/Doctrine/Table.php at line 2554

isGenerator

public boolean isGenerator()

Check whether this table was created by a record generator or not


/Doctrine/Table.php at line 570

isIdentifier

public boolean isIdentifier(string fieldName)

Checks whether a field is in the primary key.

Checks if $fieldName is part of the table identifier, which defines the one-column or multi-column primary key.

Parameters:
fieldName - The field name
Returns:
TRUE if the field is part of the table identifier/primary key field(s),

/Doctrine/Table.php at line 585

isIdentifierAutoincrement

public boolean isIdentifierAutoincrement()

Checks whether a field identifier is of type autoincrement.

This method checks if the primary key is a AUTOINCREMENT column or if the table uses a natural key.

Returns:
TRUE if the identifier is autoincrement FALSE otherwise

/Doctrine/Table.php at line 596

isIdentifierComposite

public boolean isIdentifierComposite()

Checks whether a field identifier is a composite key.

Returns:
TRUE if the identifier is a composite key, FALSE otherwise

/Doctrine/Table.php at line 556

isInheritedColumn

public boolean isInheritedColumn(mixed columnName, $columnName The)

Checks whether a column is inherited from a component further up in the hierarchy.

Parameters:
The - column name
Returns:
TRUE if column is inherited, FALSE otherwise.

/Doctrine/Table.php at line 2423

isTree

public boolean isTree()

Determines if table acts as tree.

Returns:
if tree return true, otherwise returns false

/Doctrine/Table.php at line 2320

prepareValue

public mixed prepareValue(mixed fieldName, string value, string typeHint, string field)

Performs special data preparation.

This method returns a representation of a field data, depending on the type of the given column.

1. It unserializes array and object typed columns 2. Uncompresses gzip typed columns 3. Initializes special null object pointer for null values (for fast column existence checking purposes)

example: $field = 'name'; $value = null; $table->prepareValue($field, $value); // Doctrine_Null

Throws:
if unserialization of array/object typed column fails or
if uncompression of gzip typed column fails *
Parameters:
field - the name of the field
value - field value
typeHint - Type hint used to pass in the type of the value to prepare if it is already known. This enables the method to skip the type determination. Used i.e. during hydration.
Returns:
prepared value

/Doctrine/Table.php at line 1118

processOrderBy

public string processOrderBy(string alias, string orderBy, string columnNames)

Process an order by statement to be prefixed with the passed alias and field names converted to column names if the 3rd argument is true.

Parameters:
alias - The alias to prefix columns with
orderBy - The order by to process
columnNames - Whether or not to convert field names to column names
Returns:
$orderBy

/Doctrine/Table.php at line 2170

removeColumn

public boolean removeColumn(string fieldName)

Removes a field name from the table schema information.

Returns:
true if the field is found and removed. False otherwise.

/Doctrine/Table.php at line 1796

removeRecord

public boolean removeRecord(Doctrine_Record record)

Removes a record from the identity map.

This method deletes from the cache the given record; can be used to force reloading of an object from database.

Parameters:
record - record to remove from cache
Returns:
true if the record was found and removed, false if the record wasn't found.

/Doctrine/Table.php at line 1286

setColumn

public void setColumn(string name, string type, integer length, mixed options, boolean prepend)

Adds a column to the schema.

This method does not alter the database table; @see export();

See Also:
$_columns;
Parameters:
name - column physical name
type - type of data
length - maximum length
prepend - Whether to prepend or append the new column to the column list. By default the column gets appended.
Throws:
if trying use wrongly typed parameter

/Doctrine/Table.php at line 1239

setColumnOption

public void setColumnOption(string columnName, string option, string value)

Set an individual column option


/Doctrine/Table.php at line 1218

setColumnOptions

public void setColumnOptions(string columnName, mixed options, array validators)

Customize the array of options for a column or multiple columns. First argument can be a single field/column name or an array of them. The second argument is an array of options.

[php] public function setTableDefinition() { parent::setTableDefinition(); $this->setColumnOptions('username', array( 'unique' => true )); }


/Doctrine/Table.php at line 1264

setColumns

public void setColumns(array definitions)

Set multiple column definitions at once


/Doctrine/Table.php at line 1489

setConnection

public Doctrine_Table setConnection(mixed conn)

Sets the default connection for this table.

This method assign the connection which this table will use to create queries.

Params:
Doctrine_Connection a connection object
Returns:
this object; fluent interface

/Doctrine/Table.php at line 2276

setData

public void setData(array data)

Doctrine uses this function internally. Users are strongly discouraged to use this function.

Parameters:
data - internal data

/Doctrine/Table.php at line 2544

setGenerator

public void setGenerator(Doctrine_Record_Generator generator)

Set the generator responsible for creating this table


/Doctrine/Table.php at line 619

setMethodOwner

public void setMethodOwner(string method, string class)

setMethodOwner


/Doctrine/Table.php at line 1061

setOption

public Doctrine_Table setOption(string name, mixed value)

Sets an option for the table.

This method sets an option and returns this object in order to allow flexible method chaining.

See Also:
for available options
Parameters:
name - the name of the option to set
value - the value of the option
Returns:
this object

/Doctrine/Table.php at line 817

setOptions

public void setOptions(array options)

Sets all the options.

This method sets options of the table that are specified in the argument. It has no effect on other options.

Parameters:
options - keys are option names

/Doctrine/Table.php at line 2413

setTableName

public void setTableName(string tableName)

sets the table name in the schema definition.


/Doctrine/Table.php at line 919

unique

public void unique(array fields, array options, bool createUniqueIndex)

Defines a n-uple of fields that must be unique for every record.

This method Will automatically add UNIQUE index definition and validate the values on save. The UNIQUE index is not created in the database until you use @see export().

Parameters:
fields - values are fieldnames
options - array of options for unique validator
createUniqueIndex - Whether or not to create a unique index in the database

/Doctrine/Table.php at line 2680

unshiftFilter

public Doctrine_Table unshiftFilter(Doctrine_Record_Filter filter)

unshiftFilter

Returns:
this object (provides a fluent interface)

/Doctrine/Table.php at line 2036

validateField

public Doctrine_Validator_ErrorStack validateField(string fieldName, string value, Doctrine_Record record)

Validates a given field using table ATTR_VALIDATE rules.

See Also:
Doctrine_Core::ATTR_VALIDATE
Parameters:
record - record to consider; if it does not exists, it is created
Returns:
$errorStack

/Doctrine/Table.php at line 2121

validateUniques

public void validateUniques(Doctrine_Record record)

Validates all the unique indexes.

This methods validates 'unique' sets of fields for the given Doctrine_Record instance. Pushes error to the record error stack if they are generated.


Doctrine