Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
dad31375
Commit
dad31375
authored
Feb 07, 2008
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanups
parent
0892647f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
357 deletions
+48
-357
Hydrator.php
lib/Doctrine/Hydrator.php
+2
-0
Record.php
lib/Doctrine/Record.php
+35
-71
Abstract.php
lib/Doctrine/Record/Abstract.php
+11
-286
No files found.
lib/Doctrine/Hydrator.php
View file @
dad31375
...
@@ -270,6 +270,8 @@ class Doctrine_Hydrator extends Doctrine_Hydrator_Abstract
...
@@ -270,6 +270,8 @@ class Doctrine_Hydrator extends Doctrine_Hydrator_Abstract
end
(
$coll
);
end
(
$coll
);
$prev
[
$dqlAlias
]
=&
$coll
[
key
(
$coll
)];
$prev
[
$dqlAlias
]
=&
$coll
[
key
(
$coll
)];
}
}
}
else
if
(
$coll
instanceof
Doctrine_Record
)
{
$prev
[
$dqlAlias
]
=
$coll
;
}
else
if
(
count
(
$coll
)
>
0
)
{
}
else
if
(
count
(
$coll
)
>
0
)
{
$prev
[
$dqlAlias
]
=
$coll
->
getLast
();
$prev
[
$dqlAlias
]
=
$coll
->
getLast
();
}
else
if
(
isset
(
$prev
[
$dqlAlias
]))
{
}
else
if
(
isset
(
$prev
[
$dqlAlias
]))
{
...
...
lib/Doctrine/Record.php
View file @
dad31375
...
@@ -236,8 +236,8 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -236,8 +236,8 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
*
*
* @return void
* @return void
*/
*/
public
function
setUp
()
/*
public function setUp()
{
}
{ }
*/
/**
/**
* construct
* construct
...
@@ -433,6 +433,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -433,6 +433,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
*
*
* @param boolean $overwrite whether or not to overwrite the already set values
* @param boolean $overwrite whether or not to overwrite the already set values
* @return boolean
* @return boolean
* @todo Maybe better placed in the Mapper?
*/
*/
public
function
assignDefaultValues
(
$overwrite
=
false
)
public
function
assignDefaultValues
(
$overwrite
=
false
)
{
{
...
@@ -462,6 +463,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -462,6 +463,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
*
*
* @param array $data data array to be cleaned
* @param array $data data array to be cleaned
* @return array $tmp values cleaned from data
* @return array $tmp values cleaned from data
* @todo Maybe better placed in the Mapper?
*/
*/
public
function
cleanData
(
&
$data
)
public
function
cleanData
(
&
$data
)
{
{
...
@@ -503,6 +505,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -503,6 +505,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
*
*
* @param boolean $exists whether or not this record exists in persistent data store
* @param boolean $exists whether or not this record exists in persistent data store
* @return void
* @return void
* @todo Maybe better placed in the Mapper?
*/
*/
private
function
prepareIdentifiers
(
$exists
=
true
)
private
function
prepareIdentifiers
(
$exists
=
true
)
{
{
...
@@ -692,6 +695,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -692,6 +695,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
* @throws Doctrine_Record_Exception When the refresh operation fails (when the database row
* @throws Doctrine_Record_Exception When the refresh operation fails (when the database row
* this record represents does not exist anymore)
* this record represents does not exist anymore)
* @return boolean
* @return boolean
* @todo Logic is better placed in the Mapper. Just forward to the mapper.
*/
*/
public
function
refresh
(
$deep
=
false
)
public
function
refresh
(
$deep
=
false
)
{
{
...
@@ -741,6 +745,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -741,6 +745,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
* if set, this method only refreshes the specified related component
* if set, this method only refreshes the specified related component
*
*
* @return Doctrine_Record this object
* @return Doctrine_Record this object
* @todo Logic is better placed in the Mapper. Just forward to the mapper.
*/
*/
public
function
refreshRelated
(
$name
=
null
)
public
function
refreshRelated
(
$name
=
null
)
{
{
...
@@ -766,27 +771,18 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -766,27 +771,18 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
}
}
/**
/**
* getTable
* Gets the current property values.
* returns the table object for this record
*
* @return Doctrine_Table a Doctrine_Table object
*/
public
function
getTable
()
{
return
$this
->
_table
;
}
/**
* getData
* return all the internal data
*
*
* @return array
an array containing all the properties
* @return array
The current properties and their values.
*/
*/
public
function
getData
()
public
function
getData
()
{
{
return
$this
->
_data
;
return
$this
->
_data
;
}
}
/**
*
*/
public
function
getValues
()
public
function
getValues
()
{
{
return
$this
->
_values
;
return
$this
->
_values
;
...
@@ -870,8 +866,8 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -870,8 +866,8 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
}
catch
(
Doctrine_Relation_Exception
$e
)
{
}
catch
(
Doctrine_Relation_Exception
$e
)
{
//echo $this->_domainClassName . "<br />";
//echo $this->_domainClassName . "<br />";
//var_dump($this->_values);
//var_dump($this->_values);
echo
$e
->
getTraceAsString
();
//
echo $e->getTraceAsString();
echo
"<br /><br />"
;
//
echo "<br /><br />";
foreach
(
$this
->
_table
->
getFilters
()
as
$filter
)
{
foreach
(
$this
->
_table
->
getFilters
()
as
$filter
)
{
if
((
$value
=
$filter
->
filterGet
(
$this
,
$fieldName
,
$value
))
!==
null
)
{
if
((
$value
=
$filter
->
filterGet
(
$this
,
$fieldName
,
$value
))
!==
null
)
{
return
$value
;
return
$value
;
...
@@ -889,6 +885,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -889,6 +885,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
* @param string $name the name of the mapped value
* @param string $name the name of the mapped value
* @param mixed $value mixed value to be mapped
* @param mixed $value mixed value to be mapped
* @return void
* @return void
* @todo Maybe better placed in the Mapper.
*/
*/
public
function
mapValue
(
$name
,
$value
)
public
function
mapValue
(
$name
,
$value
)
{
{
...
@@ -967,7 +964,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -967,7 +964,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
}
}
/**
/**
*
DESCRIBE WHAT THIS METHOD DOES, PLEASE!
*
Sets a related component.
* @todo Refactor. What about composite keys?
* @todo Refactor. What about composite keys?
*/
*/
private
function
_coreSetRelated
(
$name
,
$value
)
private
function
_coreSetRelated
(
$name
,
$value
)
...
@@ -1144,19 +1141,6 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -1144,19 +1141,6 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
return
$a
;
return
$a
;
}
}
/**
* REDUNDANT?
*/
/*public function modifiedFields()
{
$a = array();
foreach ($this->_modified as $k => $v) {
$a[$v] = $this->_data[$v];
}
return $a;
}*/
/**
/**
* getPrepared
* getPrepared
*
*
...
@@ -1166,6 +1150,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -1166,6 +1150,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
* @param array $array
* @param array $array
* @return array
* @return array
* @todo What about a little bit more expressive name? getPreparedData?
* @todo What about a little bit more expressive name? getPreparedData?
* @todo Maybe not the best place here ... need to think about it.
*/
*/
public
function
getPrepared
(
array
$array
=
array
())
public
function
getPrepared
(
array
$array
=
array
())
{
{
...
@@ -1212,6 +1197,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -1212,6 +1197,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
}
}
// @todo cleanup
// @todo cleanup
// populates the discriminator field in Single & Class Table Inheritance
if
(
$this
->
_table
->
getInheritanceType
()
==
Doctrine
::
INHERITANCETYPE_JOINED
||
if
(
$this
->
_table
->
getInheritanceType
()
==
Doctrine
::
INHERITANCETYPE_JOINED
||
$this
->
_table
->
getInheritanceType
()
==
Doctrine
::
INHERITANCETYPE_SINGLE_TABLE
)
{
$this
->
_table
->
getInheritanceType
()
==
Doctrine
::
INHERITANCETYPE_SINGLE_TABLE
)
{
$discCol
=
$this
->
_table
->
getInheritanceOption
(
'discriminatorColumn'
);
$discCol
=
$this
->
_table
->
getInheritanceOption
(
'discriminatorColumn'
);
...
@@ -1224,7 +1210,6 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -1224,7 +1210,6 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
}
}
}
}
return
$a
;
return
$a
;
}
}
...
@@ -1235,6 +1220,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -1235,6 +1220,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
* Implementation of the Countable interface.
* Implementation of the Countable interface.
*
*
* @return integer the number of columns in this record
* @return integer the number of columns in this record
* @todo IMHO this is unintuitive.
*/
*/
public
function
count
()
public
function
count
()
{
{
...
@@ -1242,18 +1228,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -1242,18 +1228,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
}
}
/**
/**
* alias for count()
* Creates an array representation of the object's data.
*
* @return integer the number of columns in this record
*/
public
function
columnCount
()
{
return
$this
->
count
();
}
/**
* toArray
* returns the record as an array
*
*
* @param boolean $deep - Return also the relations
* @param boolean $deep - Return also the relations
* @return array
* @return array
...
@@ -1399,10 +1374,9 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -1399,10 +1374,9 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
}
}
/**
/**
* exists
* Checks whether the entity already has a persistent state.
* returns true if this record is persistent, otherwise false
*
*
* @return boolean
* @return boolean
TRUE if the object is managed and has persistent state, FALSE otherwise.
*/
*/
public
function
exists
()
public
function
exists
()
{
{
...
@@ -1411,10 +1385,10 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -1411,10 +1385,10 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
}
}
/**
/**
*
isModifi
ed
*
Checks whether the entity has been modified since it was last synchroniz
ed
*
returns true if this record was modified, otherwise false
*
with the database.
*
*
* @return boolean
* @return boolean
TRUE if the object has been modified, FALSE otherwise.
*/
*/
public
function
isModified
()
public
function
isModified
()
{
{
...
@@ -1424,6 +1398,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -1424,6 +1398,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
/**
/**
* method for checking existence of properties and Doctrine_Record references
* method for checking existence of properties and Doctrine_Record references
*
* @param mixed $name name of the property or reference
* @param mixed $name name of the property or reference
* @return boolean
* @return boolean
*/
*/
...
@@ -1445,10 +1420,9 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -1445,10 +1420,9 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
}
}
/**
/**
* deletes this data access object and all the related composites
* Deletes the entity.
* this operation is isolated by a transaction
*
*
*
t
his event can be listened by the onPreDelete and onDelete listeners
*
T
his event can be listened by the onPreDelete and onDelete listeners
*
*
* @return boolean true on success, false on failure
* @return boolean true on success, false on failure
*/
*/
...
@@ -1458,8 +1432,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -1458,8 +1432,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
}
}
/**
/**
* copy
* Creates a copy of the entity.
* returns a copy of this object
*
*
* @return Doctrine_Record
* @return Doctrine_Record
*/
*/
...
@@ -1502,6 +1475,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -1502,6 +1475,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
*
*
* @param integer $id
* @param integer $id
* @return void
* @return void
* @todo Not sure this is the right place here.
*/
*/
public
function
assignIdentifier
(
$id
=
false
)
public
function
assignIdentifier
(
$id
=
false
)
{
{
...
@@ -1544,7 +1518,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -1544,7 +1518,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
* returns the value of autoincremented primary key of this object (if any)
* returns the value of autoincremented primary key of this object (if any)
*
*
* @return integer
* @return integer
* @todo Better name?
* @todo Better name?
Not sure this is the right place here.
*/
*/
final
public
function
getIncremented
()
final
public
function
getIncremented
()
{
{
...
@@ -1556,19 +1530,6 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -1556,19 +1530,6 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
return
$id
;
return
$id
;
}
}
/**
* getLast
* this method is used internally be Doctrine_Query
* it is needed to provide compatibility between
* records and collections
*
* @return Doctrine_Record
*/
public
function
getLast
()
{
return
$this
;
}
/**
/**
* hasRefence
* hasRefence
* @param string $name
* @param string $name
...
@@ -1602,7 +1563,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -1602,7 +1563,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
if
(
isset
(
$this
->
_references
[
$name
]))
{
if
(
isset
(
$this
->
_references
[
$name
]))
{
return
$this
->
_references
[
$name
];
return
$this
->
_references
[
$name
];
}
}
throw
new
Doctrine_Record_Exception
(
"Unknown reference
$name
"
);
throw
new
Doctrine_Record_Exception
(
"Unknown reference
$name
.
"
);
}
}
/**
/**
...
@@ -1667,6 +1628,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -1667,6 +1628,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
* getter for node assciated with this record
* getter for node assciated with this record
*
*
* @return mixed if tree returns Doctrine_Node otherwise returns false
* @return mixed if tree returns Doctrine_Node otherwise returns false
* @todo Should go to the NestedSet Behavior plugin.
*/
*/
public
function
getNode
()
public
function
getNode
()
{
{
...
@@ -1691,6 +1653,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -1691,6 +1653,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
* @throws Doctrine_Record_Exception if given version does not exist
* @throws Doctrine_Record_Exception if given version does not exist
* @param integer $version an integer > 1
* @param integer $version an integer > 1
* @return Doctrine_Record this object
* @return Doctrine_Record this object
* @todo Should go to the Versionable plugin.
*/
*/
public
function
revert
(
$version
)
public
function
revert
(
$version
)
{
{
...
@@ -1875,6 +1838,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -1875,6 +1838,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
/**
/**
* used to delete node from tree - MUST BE USE TO DELETE RECORD IF TABLE ACTS AS TREE
* used to delete node from tree - MUST BE USE TO DELETE RECORD IF TABLE ACTS AS TREE
*
*
* @todo Should go to the NestedSet Behavior plugin.
*/
*/
public
function
deleteNode
()
public
function
deleteNode
()
{
{
...
...
lib/Doctrine/Record/Abstract.php
View file @
dad31375
...
@@ -53,19 +53,24 @@ abstract class Doctrine_Record_Abstract extends Doctrine_Access
...
@@ -53,19 +53,24 @@ abstract class Doctrine_Record_Abstract extends Doctrine_Access
* @deprecated
* @deprecated
*/
*/
public
function
setUp
()
public
function
setUp
()
{}
public
static
function
initMapping
(
Doctrine_MetadataClass
$class
)
{}
{}
/**
/**
* getTable
* getTable
* returns the
associated table object
* returns the
table object for this record
*
*
* @return Doctrine_Table the associated table object
* @return Doctrine_Table a Doctrine_Table object
* @deprecated
*/
*/
public
function
getTable
()
public
function
getTable
()
{
return
$this
->
getClassMetadata
();
}
/**
* Gets the ClassMetadata object that describes the entity class.
*/
public
function
getClassMetadata
()
{
{
return
$this
->
_table
;
return
$this
->
_table
;
}
}
...
@@ -142,284 +147,4 @@ abstract class Doctrine_Record_Abstract extends Doctrine_Access
...
@@ -142,284 +147,4 @@ abstract class Doctrine_Record_Abstract extends Doctrine_Access
$this
->
_table
->
setAttribute
(
$attr
,
$value
);
$this
->
_table
->
setAttribute
(
$attr
,
$value
);
}
}
}
}
/* THE FOLLOWING STUFF WILL ALL BE REMOVED SOON */
public
function
setTableName
(
$tableName
)
{
$this
->
_table
->
setTableName
(
$tableName
);
}
/**
* index
* defines or retrieves an index
* if the second parameter is set this method defines an index
* if not this method retrieves index named $name
*
* @param string $name the name of the index
* @param array $definition the definition array
* @return mixed
*/
public
function
index
(
$name
,
array
$definition
=
array
())
{
if
(
!
$definition
)
{
return
$this
->
_table
->
getIndex
(
$name
);
}
else
{
return
$this
->
_table
->
addIndex
(
$name
,
$definition
);
}
}
/**
*
* @deprecated Use setSubclasses()
*/
public
function
setInheritanceMap
(
$map
)
{
$this
->
_table
->
setOption
(
'inheritanceMap'
,
$map
);
}
public
function
setSubclasses
(
$map
)
{
//echo "setting inheritance map on " . get_class($this) . "<br />";
$this
->
_table
->
setOption
(
'inheritanceMap'
,
$map
);
$this
->
_table
->
setOption
(
'subclasses'
,
array_keys
(
$map
));
$this
->
_table
->
setInheritanceType
(
Doctrine
::
INHERITANCETYPE_SINGLE_TABLE
);
}
/**
* option
* sets or retrieves an option
*
* @see Doctrine_Table::$options availible options
* @param mixed $name the name of the option
* @param mixed $value options value
* @return mixed
*/
public
function
option
(
$name
,
$value
=
null
)
{
if
(
$value
===
null
)
{
if
(
is_array
(
$name
))
{
foreach
(
$name
as
$k
=>
$v
)
{
$this
->
_table
->
setOption
(
$k
,
$v
);
}
}
else
{
return
$this
->
_table
->
getOption
(
$name
);
}
}
else
{
$this
->
_table
->
setOption
(
$name
,
$value
);
}
}
/**
* DEPRECATED ALSO? - REMOVE SOON
*
* ownsOne
* binds One-to-One composite relation
*
* @param string $componentName the name of the related component
* @param string $options relation options
* @see Doctrine_Relation::_$definition
* @return Doctrine_Record this object
*/
public
function
ownsOne
()
{
throw
new
Doctrine_Exception
(
'ownsMany() has been deprecated. '
.
'To create a composite relationship, use hasMany() with onDelete CASCADE option.'
);
}
/**
* DEPRECATED - REMOVE SOON
*
* ownsMany
* binds One-to-Many / Many-to-Many composite relation
*
* @param string $componentName the name of the related component
* @param string $options relation options
* @see Doctrine_Relation::_$definition
* @return Doctrine_Record this object
*/
public
function
ownsMany
()
{
throw
new
Doctrine_Exception
(
'ownsOne() has been deprecated. '
.
'To create a composite relationship, use hasOne() with onDelete CASCADE option.'
);
}
/**
* hasOne
* binds One-to-One aggregate relation
*
* @param string $componentName the name of the related component
* @param string $options relation options
* @see Doctrine_Relation::_$definition
* @return Doctrine_Record this object
*/
public
function
hasOne
()
{
$this
->
_table
->
bind
(
func_get_args
(),
Doctrine_Relation
::
ONE_AGGREGATE
);
return
$this
;
}
/**
* hasMany
* binds One-to-Many / Many-to-Many aggregate relation
*
* @param string $componentName the name of the related component
* @param string $options relation options
* @see Doctrine_Relation::_$definition
* @return Doctrine_Record this object
*/
public
function
hasMany
()
{
$this
->
_table
->
bind
(
func_get_args
(),
Doctrine_Relation
::
MANY_AGGREGATE
);
return
$this
;
}
/**
* hasColumn
* sets a column definition
*
* @param string $name
* @param string $type
* @param integer $length
* @param mixed $options
* @return void
*/
public
function
hasColumn
(
$name
,
$type
,
$length
=
2147483647
,
$options
=
""
)
{
$this
->
_table
->
setColumn
(
$name
,
$type
,
$length
,
$options
);
}
/**
* hasColumns
*
* @param array $definitions
* @return void
*/
public
function
hasColumns
(
array
$definitions
)
{
foreach
(
$definitions
as
$name
=>
$options
)
{
$this
->
hasColumn
(
$name
,
$options
[
'type'
],
$options
[
'length'
],
$options
);
}
}
/**
* loadTemplate
*
* @param string $template
*/
public
function
loadTemplate
(
$template
,
array
$options
=
array
())
{
$this
->
actAs
(
$template
,
$options
);
}
/**
* bindQueryParts
* binds query parts to given component
*
* @param array $queryParts an array of pre-bound query parts
* @return Doctrine_Record this object
*/
public
function
bindQueryParts
(
array
$queryParts
)
{
if
(
!
$this
->
_table
)
{
try
{
throw
new
Exception
();
}
catch
(
Exception
$e
)
{
echo
$e
->
getTraceAsString
()
.
"<br />"
;
}
}
$this
->
_table
->
bindQueryParts
(
$queryParts
);
return
$this
;
}
public
function
loadGenerator
(
Doctrine_Record_Generator
$generator
)
{
$generator
->
initialize
(
$this
->
_table
);
$this
->
_table
->
addGenerator
(
$generator
,
get_class
(
$generator
));
}
/**
* actAs
* loads the given plugin
*
* @param mixed $tpl
* @param array $options
*/
public
function
actAs
(
$tpl
,
array
$options
=
array
())
{
if
(
!
is_object
(
$tpl
))
{
if
(
class_exists
(
$tpl
,
true
))
{
$tpl
=
new
$tpl
(
$options
);
}
else
{
$className
=
'Doctrine_Template_'
.
$tpl
;
if
(
!
class_exists
(
$className
,
true
))
{
throw
new
Doctrine_Record_Exception
(
"Couldn't load plugin."
);
}
$tpl
=
new
$className
(
$options
);
}
}
if
(
!
(
$tpl
instanceof
Doctrine_Template
))
{
throw
new
Doctrine_Record_Exception
(
'Loaded plugin class is not an instance of Doctrine_Template.'
);
}
$className
=
get_class
(
$tpl
);
$this
->
_table
->
addTemplate
(
$className
,
$tpl
);
$tpl
->
setTable
(
$this
->
_table
);
$tpl
->
setUp
();
$tpl
->
setTableDefinition
();
return
$this
;
}
/**
*
*
*/
public
function
setInheritanceType
(
$type
,
array
$options
=
null
)
{
if
(
$type
==
Doctrine
::
INHERITANCETYPE_SINGLE_TABLE
)
{
$this
->
setSubclasses
(
$options
);
}
else
if
(
$type
==
Doctrine
::
INHERITANCETYPE_JOINED
)
{
$this
->
setSubclasses
(
$options
);
}
else
if
(
$type
==
Doctrine
::
INHERITANCETYPE_TABLE_PER_CLASS
)
{
// concrete table inheritance ...
}
$this
->
_table
->
setInheritanceType
(
$type
);
}
/**
* check
* adds a check constraint
*
* @param mixed $constraint either a SQL constraint portion or an array of CHECK constraints
* @param string $name optional constraint name
* @return Doctrine_Record this object
*/
public
function
check
(
$constraint
,
$name
=
null
)
{
if
(
is_array
(
$constraint
))
{
foreach
(
$constraint
as
$name
=>
$def
)
{
$this
->
_table
->
addCheckConstraint
(
$def
,
$name
);
}
}
else
{
$this
->
_table
->
addCheckConstraint
(
$constraint
,
$name
);
}
return
$this
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment