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
21e22ba9
Commit
21e22ba9
authored
Feb 08, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
3ab8a56e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
30 deletions
+76
-30
Table.php
lib/Doctrine/Table.php
+76
-30
No files found.
lib/Doctrine/Table.php
View file @
21e22ba9
...
...
@@ -222,14 +222,14 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
}
switch
(
count
(
$this
->
primaryKeys
))
{
case
0
:
$
definition
=
array
(
'id'
=>
new
Doctrine_Column
(
array
(
'type'
=>
'integer'
,
'length'
=>
20
,
'autoincrement'
=>
true
,
'primary'
=>
true
,
)));
$this
->
columns
=
array_merge
(
$definition
,
$this
->
columns
);
$
this
->
columns
=
array_merge
(
array
(
'id'
=>
array
(
'integer'
,
20
,
array
(
'autoincrement'
=>
true
,
'primary'
=>
true
)
)
)
,
$this
->
columns
);
$this
->
primaryKeys
[]
=
'id'
;
$this
->
identifier
=
'id'
;
...
...
@@ -243,7 +243,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
}
else
{
foreach
(
$this
->
primaryKeys
as
$pk
)
{
$e
=
$this
->
columns
[
$pk
];
$e
=
$this
->
columns
[
$pk
]
[
2
]
;
$found
=
false
;
...
...
@@ -336,7 +336,9 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
$primary
=
array
();
foreach
(
$this
->
columns
as
$name
=>
$column
)
{
$definition
=
$column
->
getDefinition
();
$definition
=
$column
[
2
];
$definition
[
'type'
]
=
$column
[
0
];
$definition
[
'length'
]
=
$column
[
1
];
switch
(
$definition
[
'type'
])
{
case
'enum'
:
...
...
@@ -515,8 +517,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
throw
new
Doctrine_Table_Exception
(
'Invalid argument given for column length'
);
}
$definition
=
array
(
'type'
=>
$type
,
'length'
=>
$length
)
+
$options
;
$this
->
columns
[
$name
]
=
new
Doctrine_Column
(
$definition
);
$this
->
columns
[
$name
]
=
array
(
$type
,
$length
,
$options
);
if
(
isset
(
$options
[
'primary'
]))
{
$this
->
primaryKeys
[]
=
$name
;
...
...
@@ -535,6 +536,25 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
{
return
$this
->
hasDefaultValues
;
}
/**
* getDefaultValueOf
* returns the default value(if any) for given column
*
* @param string $column
* @return mixed
*/
public
function
getDefaultValueOf
(
$column
)
{
$column
=
strtolower
(
$column
);
if
(
!
isset
(
$this
->
columns
[
$column
]))
{
throw
new
Doctrine_Table_Exception
(
"Couldn't get default value. Column "
.
$column
.
" doesn't exist."
);
}
if
(
isset
(
$this
->
columns
[
$column
][
2
][
'default'
]))
{
return
$this
->
columns
[
$column
][
2
][
'default'
];
}
else
{
return
null
;
}
}
/**
* @return mixed
*/
...
...
@@ -1089,8 +1109,8 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
*/
final
public
function
getEnumValues
(
$field
)
{
if
(
isset
(
$this
->
columns
[
$field
][
'values'
]))
{
return
$this
->
columns
[
$field
][
'values'
];
if
(
isset
(
$this
->
columns
[
$field
][
2
][
'values'
]))
{
return
$this
->
columns
[
$field
][
2
][
'values'
];
}
else
{
return
array
();
}
...
...
@@ -1107,7 +1127,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
if
(
$index
instanceof
Doctrine_Null
)
return
$index
;
return
isset
(
$this
->
columns
[
$field
][
'values'
][
$index
])
?
$this
->
columns
[
$field
][
'values'
][
$index
]
:
$index
;
return
isset
(
$this
->
columns
[
$field
][
2
][
'values'
][
$index
])
?
$this
->
columns
[
$field
][
2
][
'values'
][
$index
]
:
$index
;
}
/**
* enumIndex
...
...
@@ -1166,34 +1186,35 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
return
$value
;
}
/**
* get
ColumnCount
* get
DefinitionOf
*
* @return
integer the number of columns in this tabl
e
* @return
string ValueWrapper class name on success, false on failur
e
*/
public
function
get
ColumnCount
(
)
public
function
get
ValueWrapperOf
(
$column
)
{
return
$this
->
columnCount
;
if
(
isset
(
$this
->
columns
[
$column
][
2
][
'wrapper'
]))
{
return
$this
->
columns
[
$column
][
2
][
'wrapper'
];
}
return
false
;
}
/**
* getColumn
* getColumn
Count
*
* @param string $name
* @return Doctrine_Column
* @return integer the number of columns in this table
*/
public
function
getColumn
(
$name
)
final
public
function
getColumnCount
(
)
{
if
(
isset
(
$this
->
columns
[
$name
]))
{
return
$this
->
columns
[
$name
];
}
throw
new
Doctrine_Table_Exception
(
'Unknown column '
.
$name
);
return
$this
->
columnCount
;
}
/**
* returns all columns and their definitions
*
* @return array
*/
public
function
getColumns
()
final
public
function
getColumns
()
{
return
$this
->
columns
;
}
...
...
@@ -1206,6 +1227,31 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
{
return
array_keys
(
$this
->
columns
);
}
/**
* getDefinitionOf
*
* @return mixed array on success, false on failure
*/
public
function
getDefinitionOf
(
$column
)
{
if
(
isset
(
$this
->
columns
[
$column
]))
{
return
$this
->
columns
[
$column
];
}
return
false
;
}
/**
* getTypeOf
*
* @return mixed string on success, false on failure
*/
public
function
getTypeOf
(
$column
)
{
if
(
isset
(
$this
->
columns
[
$column
]))
{
return
$this
->
columns
[
$column
][
0
];
}
return
false
;
}
/**
* setData
* doctrine uses this function internally
...
...
@@ -1275,9 +1321,9 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
{
return
$this
->
options
[
'tableName'
];
}
public
function
setTableName
(
$
n
ame
)
public
function
setTableName
(
$
tableN
ame
)
{
$this
->
options
[
'tableName'
]
=
$
name
;
$this
->
options
[
'tableName'
]
=
$
tableName
;
}
/**
* determine if table acts as tree
...
...
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