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
e3719874
Commit
e3719874
authored
Jun 27, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
c7d5ea09
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
304 additions
and
191 deletions
+304
-191
Record.php
lib/Doctrine/Record.php
+4
-190
Abstract.php
lib/Doctrine/Record/Abstract.php
+227
-0
Table.php
lib/Doctrine/Table.php
+5
-1
Template.php
lib/Doctrine/Template.php
+68
-0
No files found.
lib/Doctrine/Record.php
View file @
e3719874
...
...
@@ -31,7 +31,7 @@ Doctrine::autoload('Doctrine_Access');
* @since 1.0
* @version $Revision$
*/
abstract
class
Doctrine_Record
extends
Doctrine_
Access
implements
Countable
,
IteratorAggregate
,
Serializable
abstract
class
Doctrine_Record
extends
Doctrine_
Record_Abstract
implements
Countable
,
IteratorAggregate
,
Serializable
{
/**
* STATE CONSTANTS
...
...
@@ -1309,85 +1309,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$rel
=
$this
->
_table
->
getRelation
(
$name
);
$this
->
_references
[
$name
]
=
$rel
->
fetchRelatedFor
(
$this
);
}
/**
* 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
()
{
$this
->
_table
->
bind
(
func_get_args
(),
Doctrine_Relation
::
ONE_COMPOSITE
);
return
$this
;
}
/**
* 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
()
{
$this
->
_table
->
bind
(
func_get_args
(),
Doctrine_Relation
::
MANY_COMPOSITE
);
return
$this
;
}
/**
* 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
);
}
public
function
hasColumns
(
array
$definitions
)
{
foreach
(
$definitions
as
$name
=>
$options
)
{
$this
->
hasColumn
(
$name
,
$options
[
'type'
],
$options
[
'length'
],
$options
);
}
}
/**
* merge
* merges this record with an array of values
...
...
@@ -1407,117 +1329,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
}
}
}
public
function
setAttribute
(
$attr
,
$value
)
{
$this
->
_table
->
setAttribute
(
$attr
,
$value
);
}
public
function
setTableName
(
$tableName
)
{
$this
->
_table
->
setOption
(
'tableName'
,
$tableName
);
}
public
function
setInheritanceMap
(
$map
)
{
$this
->
_table
->
setOption
(
'inheritanceMap'
,
$map
);
}
public
function
setEnumValues
(
$column
,
$values
)
{
$this
->
_table
->
setEnumValues
(
$column
,
$values
);
}
/**
* attribute
* sets or retrieves an option
*
* @see Doctrine::ATTR_* constants availible attributes
* @param mixed $attr
* @param mixed $value
* @return mixed
*/
public
function
attribute
(
$attr
,
$value
)
{
if
(
$value
==
null
)
{
if
(
is_array
(
$attr
))
{
foreach
(
$attr
as
$k
=>
$v
)
{
$this
->
_table
->
setAttribute
(
$k
,
$v
);
}
}
else
{
return
$this
->
_table
->
getAttribute
(
$attr
);
}
}
else
{
$this
->
_table
->
setAttribute
(
$attr
,
$value
);
}
}
/**
* 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
);
}
}
/**
* 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
);
}
}
/**
* addListener
*
* @param Doctrine_EventListener_Interface|Doctrine_Overloadable $listener
* @return Doctrine_Record
*/
public
function
addListener
(
$listener
,
$name
=
null
)
{
$this
->
_table
->
addListener
(
$listener
,
$name
=
null
);
return
$this
;
}
/**
* getListener
*
* @return Doctrine_EventListener_Interface|Doctrine_Overloadable
*/
public
function
getListener
()
{
return
$this
->
_table
->
getListener
();
}
/**
* setListener
*
* @param Doctrine_EventListener_Interface|Doctrine_Overloadable $listener
* @return Doctrine_Record
*/
public
function
setListener
(
$listener
)
{
$this
->
_table
->
setListener
(
$listener
);
return
$this
;
}
/**
* call
*
...
...
@@ -1574,6 +1385,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
*/
public
function
loadTemplate
(
$template
)
{
$tpl
=
new
$template
(
$this
->
_table
);
$tpl
->
setUp
();
$tpl
->
setTableDefinition
();
return
$this
;
}
/**
...
...
lib/Doctrine/Record/Abstract.php
0 → 100644
View file @
e3719874
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
Doctrine
::
autoload
(
'Doctrine_Access'
);
/**
* Doctrine_Record_Abstract
*
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @package Doctrine
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
abstract
class
Doctrine_Record_Abstract
extends
Doctrine_Access
{
/**
* addListener
*
* @param Doctrine_EventListener_Interface|Doctrine_Overloadable $listener
* @return Doctrine_Record
*/
public
function
addListener
(
$listener
,
$name
=
null
)
{
$this
->
_table
->
addListener
(
$listener
,
$name
=
null
);
return
$this
;
}
/**
* getListener
*
* @return Doctrine_EventListener_Interface|Doctrine_Overloadable
*/
public
function
getListener
()
{
return
$this
->
_table
->
getListener
();
}
/**
* setListener
*
* @param Doctrine_EventListener_Interface|Doctrine_Overloadable $listener
* @return Doctrine_Record
*/
public
function
setListener
(
$listener
)
{
$this
->
_table
->
setListener
(
$listener
);
return
$this
;
}
/**
* 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
);
}
}
public
function
setAttribute
(
$attr
,
$value
)
{
$this
->
_table
->
setAttribute
(
$attr
,
$value
);
}
public
function
setTableName
(
$tableName
)
{
$this
->
_table
->
setOption
(
'tableName'
,
$tableName
);
}
public
function
setInheritanceMap
(
$map
)
{
$this
->
_table
->
setOption
(
'inheritanceMap'
,
$map
);
}
public
function
setEnumValues
(
$column
,
$values
)
{
$this
->
_table
->
setEnumValues
(
$column
,
$values
);
}
/**
* attribute
* sets or retrieves an option
*
* @see Doctrine::ATTR_* constants availible attributes
* @param mixed $attr
* @param mixed $value
* @return mixed
*/
public
function
attribute
(
$attr
,
$value
)
{
if
(
$value
==
null
)
{
if
(
is_array
(
$attr
))
{
foreach
(
$attr
as
$k
=>
$v
)
{
$this
->
_table
->
setAttribute
(
$k
,
$v
);
}
}
else
{
return
$this
->
_table
->
getAttribute
(
$attr
);
}
}
else
{
$this
->
_table
->
setAttribute
(
$attr
,
$value
);
}
}
/**
* 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
);
}
}
/**
* 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
()
{
$this
->
_table
->
bind
(
func_get_args
(),
Doctrine_Relation
::
ONE_COMPOSITE
);
return
$this
;
}
/**
* 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
()
{
$this
->
_table
->
bind
(
func_get_args
(),
Doctrine_Relation
::
MANY_COMPOSITE
);
return
$this
;
}
/**
* 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
);
}
public
function
hasColumns
(
array
$definitions
)
{
foreach
(
$definitions
as
$name
=>
$options
)
{
$this
->
hasColumn
(
$name
,
$options
[
'type'
],
$options
[
'length'
],
$options
);
}
}
}
lib/Doctrine/Table.php
View file @
e3719874
...
...
@@ -509,6 +509,10 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
$options
=
array
();
$options
[
'type'
]
=
$type
;
if
(
!
isset
(
$args
[
1
]))
{
$args
[
1
]
=
array
();
}
// the following is needed for backwards compatibility
if
(
is_string
(
$args
[
1
]))
{
if
(
!
isset
(
$args
[
2
]))
{
...
...
@@ -539,7 +543,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
$options
=
array_merge
(
$args
[
2
],
$options
);
$this
->
_parser
->
bind
(
$args
[
0
],
$options
);
}
else
{
}
else
{
$options
=
array_merge
(
$args
[
1
],
$options
);
$this
->
_parser
->
bind
(
$args
[
0
],
$options
);
}
...
...
lib/Doctrine/Template.php
0 → 100644
View file @
e3719874
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_Template
*
* @package Doctrine
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class
Doctrine_Template
extends
Doctrine_Record_Abstract
{
/**
* @param Doctrine_Table $_table reference to associated Doctrine_Table instance
*/
protected
$_table
;
/**
* constructor, creates tree with reference to table and any options
*
* @param Doctrine_Table $_table the table object this Template belongs to
*/
public
function
__construct
(
Doctrine_Table
$table
)
{
$this
->
_table
=
$table
;
}
/**
* getTable
* returns the associated table object
*
* @return Doctrine_Table the associated table object
*/
public
function
getTable
()
{
return
$this
->
_table
;
}
public
function
setUp
()
{
}
public
function
setTableDefinition
()
{
}
}
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