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
e24d9c69
Commit
e24d9c69
authored
Sep 20, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring the table class
parent
2169cbe9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
59 deletions
+56
-59
Table.php
lib/Doctrine/Table.php
+56
-59
No files found.
lib/Doctrine/Table.php
View file @
e24d9c69
...
...
@@ -36,11 +36,11 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
/**
* @var array $data temporary data which is then loaded into Doctrine_Record::$data
*/
private
$data
=
array
();
private
$
_
data
=
array
();
/**
* @var array $primaryKeys an array containing all primary key column names
*/
private
$primaryKeys
=
array
();
private
$primaryKeys
=
array
();
/**
* @var mixed $identifier
*/
...
...
@@ -150,7 +150,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
/**
* @var Doctrine_Tree $tree tree object associated with this table
*/
protected
$tree
;
protected
$
_
tree
;
/**
* @var Doctrine_Relation_Parser $_parser relation parser object
*/
...
...
@@ -237,55 +237,52 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
$this
->
_identifierType
=
Doctrine
::
IDENTIFIER_AUTOINC
;
$this
->
columnCount
++
;
break
;
default
:
if
(
count
(
$this
->
primaryKeys
)
>
1
)
{
$this
->
_identifier
=
$this
->
primaryKeys
;
$this
->
_identifierType
=
Doctrine
::
IDENTIFIER_COMPOSITE
;
}
else
{
foreach
(
$this
->
primaryKeys
as
$pk
)
{
$e
=
$this
->
columns
[
$pk
];
case
1
:
foreach
(
$this
->
primaryKeys
as
$pk
)
{
$e
=
$this
->
columns
[
$pk
];
$found
=
false
;
$found
=
false
;
foreach
(
$e
as
$option
=>
$value
)
{
if
(
$found
)
foreach
(
$e
as
$option
=>
$value
)
{
if
(
$found
)
break
;
$e2
=
explode
(
':'
,
$option
);
switch
(
strtolower
(
$e2
[
0
]))
{
case
'autoincrement'
:
case
'autoinc'
:
$this
->
_identifierType
=
Doctrine
::
IDENTIFIER_AUTOINC
;
$found
=
true
;
break
;
case
'seq'
:
case
'sequence'
:
$this
->
_identifierType
=
Doctrine
::
IDENTIFIER_SEQUENCE
;
$found
=
true
;
if
(
$value
)
{
$this
->
options
[
'sequenceName'
]
=
$value
;
$e2
=
explode
(
':'
,
$option
);
switch
(
strtolower
(
$e2
[
0
]))
{
case
'autoincrement'
:
case
'autoinc'
:
$this
->
_identifierType
=
Doctrine
::
IDENTIFIER_AUTOINC
;
$found
=
true
;
break
;
case
'seq'
:
case
'sequence'
:
$this
->
_identifierType
=
Doctrine
::
IDENTIFIER_SEQUENCE
;
$found
=
true
;
if
(
$value
)
{
$this
->
options
[
'sequenceName'
]
=
$value
;
}
else
{
if
((
$sequence
=
$this
->
getAttribute
(
Doctrine
::
ATTR_DEFAULT_SEQUENCE
))
!==
null
)
{
$this
->
options
[
'sequenceName'
]
=
$sequence
;
}
else
{
if
((
$sequence
=
$this
->
getAttribute
(
Doctrine
::
ATTR_DEFAULT_SEQUENCE
))
!==
null
)
{
$this
->
options
[
'sequenceName'
]
=
$sequence
;
}
else
{
$this
->
options
[
'sequenceName'
]
=
$this
->
_conn
->
getSequenceName
(
$this
->
options
[
'tableName'
]);
}
$this
->
options
[
'sequenceName'
]
=
$this
->
_conn
->
getSequenceName
(
$this
->
options
[
'tableName'
]);
}
break
;
}
}
if
(
!
isset
(
$this
->
_identifierType
))
{
$this
->
_identifierType
=
Doctrine
::
IDENTIFIER_NATURAL
;
}
break
;
}
$this
->
_identifier
=
$pk
;
}
}
if
(
!
isset
(
$this
->
_identifierType
))
{
$this
->
_identifierType
=
Doctrine
::
IDENTIFIER_NATURAL
;
}
$this
->
_identifier
=
$pk
;
}
break
;
default
:
$this
->
_identifier
=
$this
->
primaryKeys
;
$this
->
_identifierType
=
Doctrine
::
IDENTIFIER_COMPOSITE
;
}
$record
->
setUp
();
// if tree, set up tree
...
...
@@ -814,9 +811,9 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
* @return Doctrine_Record
*/
public
function
create
(
array
$array
=
array
())
{
$this
->
data
=
$array
;
$this
->
_
data
=
$array
;
$record
=
new
$this
->
options
[
'name'
](
$this
,
true
);
$this
->
data
=
array
();
$this
->
_
data
=
array
();
return
$record
;
}
/**
...
...
@@ -925,8 +922,8 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
*/
public
function
getRecord
()
{
if
(
!
empty
(
$this
->
data
))
{
$this
->
data
=
array_change_key_case
(
$this
->
data
,
CASE_LOWER
);
if
(
!
empty
(
$this
->
_
data
))
{
$this
->
_data
=
array_change_key_case
(
$this
->
_
data
,
CASE_LOWER
);
$key
=
$this
->
getIdentifier
();
...
...
@@ -936,18 +933,18 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
$found
=
false
;
foreach
(
$key
as
$k
)
{
if
(
!
isset
(
$this
->
data
[
$k
]))
{
if
(
!
isset
(
$this
->
_
data
[
$k
]))
{
// primary key column not found return new record
$found
=
true
;
break
;
}
$id
[]
=
$this
->
data
[
$k
];
$id
[]
=
$this
->
_
data
[
$k
];
}
if
(
$found
)
{
$recordName
=
$this
->
getClassnameToReturn
();
$record
=
new
$recordName
(
$this
,
true
);
$this
->
data
=
array
();
$this
->
_
data
=
array
();
return
$record
;
}
...
...
@@ -957,13 +954,13 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
if
(
isset
(
$this
->
_identityMap
[
$id
]))
{
$record
=
$this
->
_identityMap
[
$id
];
$record
->
hydrate
(
$this
->
data
);
$record
->
hydrate
(
$this
->
_
data
);
}
else
{
$recordName
=
$this
->
getClassnameToReturn
();
$record
=
new
$recordName
(
$this
);
$this
->
_identityMap
[
$id
]
=
$record
;
}
$this
->
data
=
array
();
$this
->
_
data
=
array
();
}
else
{
$recordName
=
$this
->
getClassnameToReturn
();
$record
=
new
$recordName
(
$this
,
true
);
...
...
@@ -997,7 +994,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
$inheritanceMap
=
$table
->
getOption
(
'inheritanceMap'
);
$nomatch
=
false
;
foreach
(
$inheritanceMap
as
$key
=>
$value
)
{
if
(
!
isset
(
$this
->
data
[
$key
])
||
$this
->
data
[
$key
]
!=
$value
)
{
if
(
!
isset
(
$this
->
_data
[
$key
])
||
$this
->
_
data
[
$key
]
!=
$value
)
{
$nomatch
=
true
;
break
;
}
...
...
@@ -1023,9 +1020,9 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
$params
=
array_merge
(
array
(
$id
),
array_values
(
$this
->
options
[
'inheritanceMap'
]));
$this
->
data
=
$this
->
_conn
->
execute
(
$query
,
$params
)
->
fetch
(
PDO
::
FETCH_ASSOC
);
$this
->
_
data
=
$this
->
_conn
->
execute
(
$query
,
$params
)
->
fetch
(
PDO
::
FETCH_ASSOC
);
if
(
$this
->
data
===
false
)
if
(
$this
->
_
data
===
false
)
return
false
;
}
return
$this
->
getRecord
();
...
...
@@ -1160,7 +1157,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
*/
public
function
setData
(
array
$data
)
{
$this
->
data
=
$data
;
$this
->
_
data
=
$data
;
}
/**
* returns internal data, used by Doctrine_Record instances
...
...
@@ -1170,7 +1167,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
*/
public
function
getData
()
{
return
$this
->
data
;
return
$this
->
_
data
;
}
/**
* prepareValue
...
...
@@ -1244,14 +1241,14 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
*/
public
function
getTree
()
{
if
(
isset
(
$this
->
options
[
'treeImpl'
]))
{
if
(
!
$this
->
tree
)
{
if
(
!
$this
->
_
tree
)
{
$options
=
isset
(
$this
->
options
[
'treeOptions'
])
?
$this
->
options
[
'treeOptions'
]
:
array
();
$this
->
tree
=
Doctrine_Tree
::
factory
(
$this
,
$this
->
_
tree
=
Doctrine_Tree
::
factory
(
$this
,
$this
->
options
[
'treeImpl'
],
$options
);
}
return
$this
->
tree
;
return
$this
->
_
tree
;
}
return
false
;
}
...
...
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