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
5f1c8d10
Commit
5f1c8d10
authored
Aug 21, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
a0958f7d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
22 deletions
+22
-22
Table.php
Doctrine/Table.php
+22
-22
No files found.
Doctrine/Table.php
View file @
5f1c8d10
...
@@ -44,9 +44,9 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
...
@@ -44,9 +44,9 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
*/
*/
private
$query
;
private
$query
;
/**
/**
* @var Doctrine_
Session $session Doctrine_Sess
ion object that created this table
* @var Doctrine_
Connection $connection Doctrine_Connect
ion object that created this table
*/
*/
private
$
sess
ion
;
private
$
connect
ion
;
/**
/**
* @var string $name name of the component, for example component name of the GroupTable is 'Group'
* @var string $name name of the component, for example component name of the GroupTable is 'Group'
*/
*/
...
@@ -111,14 +111,14 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
...
@@ -111,14 +111,14 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
/**
/**
* the constructor
* the constructor
* @throws Doctrine_ManagerException if there are no opened
sess
ions
* @throws Doctrine_ManagerException if there are no opened
connect
ions
* @throws Doctrine_TableException if there is already an instance of this table
* @throws Doctrine_TableException if there is already an instance of this table
* @return void
* @return void
*/
*/
public
function
__construct
(
$name
)
{
public
function
__construct
(
$name
)
{
$this
->
session
=
Doctrine_Manager
::
getInstance
()
->
getCurrentSess
ion
();
$this
->
connection
=
Doctrine_Manager
::
getInstance
()
->
getCurrentConnect
ion
();
$this
->
setParent
(
$this
->
sess
ion
);
$this
->
setParent
(
$this
->
connect
ion
);
$this
->
name
=
$name
;
$this
->
name
=
$name
;
...
@@ -206,7 +206,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
...
@@ -206,7 +206,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
endswitch
;
endswitch
;
if
(
Doctrine_DataDict
::
isValidClassname
(
$class
->
getName
())
&&
$this
->
getAttribute
(
Doctrine
::
ATTR_CREATE_TABLES
))
{
if
(
Doctrine_DataDict
::
isValidClassname
(
$class
->
getName
())
&&
$this
->
getAttribute
(
Doctrine
::
ATTR_CREATE_TABLES
))
{
$dict
=
new
Doctrine_DataDict
(
$this
->
get
Sess
ion
()
->
getDBH
());
$dict
=
new
Doctrine_DataDict
(
$this
->
get
Connect
ion
()
->
getDBH
());
$dict
->
createTable
(
$this
->
tableName
,
$this
->
columns
);
$dict
->
createTable
(
$this
->
tableName
,
$this
->
columns
);
}
}
...
@@ -224,7 +224,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
...
@@ -224,7 +224,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
$this
->
query
=
"SELECT "
.
implode
(
", "
,
array_keys
(
$this
->
columns
))
.
" FROM "
.
$this
->
getTableName
();
$this
->
query
=
"SELECT "
.
implode
(
", "
,
array_keys
(
$this
->
columns
))
.
" FROM "
.
$this
->
getTableName
();
// check if an instance of this table is already initialized
// check if an instance of this table is already initialized
if
(
!
$this
->
sess
ion
->
addTable
(
$this
))
if
(
!
$this
->
connect
ion
->
addTable
(
$this
))
throw
new
Doctrine_Table_Exception
();
throw
new
Doctrine_Table_Exception
();
$this
->
initComponents
();
$this
->
initComponents
();
...
@@ -501,10 +501,10 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
...
@@ -501,10 +501,10 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
return
$this
->
name
;
return
$this
->
name
;
}
}
/**
/**
* @return Doctrine_
Sess
ion
* @return Doctrine_
Connect
ion
*/
*/
final
public
function
get
Sess
ion
()
{
final
public
function
get
Connect
ion
()
{
return
$this
->
sess
ion
;
return
$this
->
connect
ion
;
}
}
/**
/**
* @return Doctrine_Cache
* @return Doctrine_Cache
...
@@ -551,7 +551,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
...
@@ -551,7 +551,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
$alias
=
$name
;
$alias
=
$name
;
$name
=
$this
->
bound
[
$alias
][
3
];
$name
=
$this
->
bound
[
$alias
][
3
];
$table
=
$this
->
sess
ion
->
getTable
(
$name
);
$table
=
$this
->
connect
ion
->
getTable
(
$name
);
if
(
$component
==
$this
->
name
||
in_array
(
$component
,
$this
->
parents
))
{
if
(
$component
==
$this
->
name
||
in_array
(
$component
,
$this
->
parents
))
{
...
@@ -597,7 +597,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
...
@@ -597,7 +597,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
if
(
$e2
[
0
]
!=
$component
)
if
(
$e2
[
0
]
!=
$component
)
throw
new
Doctrine_Mapping_Exception
(
$e2
[
0
]
.
" doesn't match "
.
$component
);
throw
new
Doctrine_Mapping_Exception
(
$e2
[
0
]
.
" doesn't match "
.
$component
);
$associationTable
=
$this
->
sess
ion
->
getTable
(
$e2
[
0
]);
$associationTable
=
$this
->
connect
ion
->
getTable
(
$e2
[
0
]);
if
(
count
(
$fields
)
>
1
)
{
if
(
count
(
$fields
)
>
1
)
{
// SELF-REFERENCING THROUGH JOIN TABLE
// SELF-REFERENCING THROUGH JOIN TABLE
...
@@ -683,7 +683,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
...
@@ -683,7 +683,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
$params
=
array_merge
(
$id
,
array_values
(
$this
->
inheritanceMap
));
$params
=
array_merge
(
$id
,
array_values
(
$this
->
inheritanceMap
));
$stmt
=
$this
->
sess
ion
->
execute
(
$query
,
$params
);
$stmt
=
$this
->
connect
ion
->
execute
(
$query
,
$params
);
$this
->
data
=
$stmt
->
fetch
(
PDO
::
FETCH_ASSOC
);
$this
->
data
=
$stmt
->
fetch
(
PDO
::
FETCH_ASSOC
);
...
@@ -715,7 +715,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
...
@@ -715,7 +715,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
* @return Doctrine_Collection
* @return Doctrine_Collection
*/
*/
public
function
findAll
()
{
public
function
findAll
()
{
$graph
=
new
Doctrine_Query
(
$this
->
sess
ion
);
$graph
=
new
Doctrine_Query
(
$this
->
connect
ion
);
$users
=
$graph
->
query
(
"FROM "
.
$this
->
name
);
$users
=
$graph
->
query
(
"FROM "
.
$this
->
name
);
return
$users
;
return
$users
;
}
}
...
@@ -729,7 +729,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
...
@@ -729,7 +729,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
* @return Doctrine_Collection
* @return Doctrine_Collection
*/
*/
public
function
findBySql
(
$dql
,
array
$params
=
array
())
{
public
function
findBySql
(
$dql
,
array
$params
=
array
())
{
$q
=
new
Doctrine_Query
(
$this
->
sess
ion
);
$q
=
new
Doctrine_Query
(
$this
->
connect
ion
);
$users
=
$q
->
query
(
"FROM "
.
$this
->
name
.
" WHERE "
.
$dql
,
$params
);
$users
=
$q
->
query
(
"FROM "
.
$this
->
name
.
" WHERE "
.
$dql
,
$params
);
return
$users
;
return
$users
;
}
}
...
@@ -791,7 +791,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
...
@@ -791,7 +791,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
$params
=
array_merge
(
array
(
$id
),
array_values
(
$this
->
inheritanceMap
));
$params
=
array_merge
(
array
(
$id
),
array_values
(
$this
->
inheritanceMap
));
$this
->
data
=
$this
->
sess
ion
->
execute
(
$query
,
$params
)
->
fetch
(
PDO
::
FETCH_ASSOC
);
$this
->
data
=
$this
->
connect
ion
->
execute
(
$query
,
$params
)
->
fetch
(
PDO
::
FETCH_ASSOC
);
if
(
$this
->
data
===
false
)
if
(
$this
->
data
===
false
)
throw
new
Doctrine_Find_Exception
();
throw
new
Doctrine_Find_Exception
();
...
@@ -811,14 +811,14 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
...
@@ -811,14 +811,14 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
* @return integer
* @return integer
*/
*/
public
function
count
()
{
public
function
count
()
{
$a
=
$this
->
sess
ion
->
getDBH
()
->
query
(
"SELECT COUNT(1) FROM "
.
$this
->
tableName
)
->
fetch
(
PDO
::
FETCH_NUM
);
$a
=
$this
->
connect
ion
->
getDBH
()
->
query
(
"SELECT COUNT(1) FROM "
.
$this
->
tableName
)
->
fetch
(
PDO
::
FETCH_NUM
);
return
current
(
$a
);
return
current
(
$a
);
}
}
/**
/**
* @return Doctrine_Query a Doctrine_Query object
* @return Doctrine_Query a Doctrine_Query object
*/
*/
public
function
getQueryObject
()
{
public
function
getQueryObject
()
{
$graph
=
new
Doctrine_Query
(
$this
->
get
Sess
ion
());
$graph
=
new
Doctrine_Query
(
$this
->
get
Connect
ion
());
$graph
->
load
(
$this
->
getComponentName
());
$graph
->
load
(
$this
->
getComponentName
());
return
$graph
;
return
$graph
;
}
}
...
@@ -831,12 +831,12 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
...
@@ -831,12 +831,12 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
*/
*/
public
function
execute
(
$query
,
array
$array
=
array
(),
$limit
=
null
,
$offset
=
null
)
{
public
function
execute
(
$query
,
array
$array
=
array
(),
$limit
=
null
,
$offset
=
null
)
{
$coll
=
new
Doctrine_Collection
(
$this
);
$coll
=
new
Doctrine_Collection
(
$this
);
$query
=
$this
->
sess
ion
->
modifyLimitQuery
(
$query
,
$limit
,
$offset
);
$query
=
$this
->
connect
ion
->
modifyLimitQuery
(
$query
,
$limit
,
$offset
);
if
(
!
empty
(
$array
))
{
if
(
!
empty
(
$array
))
{
$stmt
=
$this
->
sess
ion
->
getDBH
()
->
prepare
(
$query
);
$stmt
=
$this
->
connect
ion
->
getDBH
()
->
prepare
(
$query
);
$stmt
->
execute
(
$array
);
$stmt
->
execute
(
$array
);
}
else
{
}
else
{
$stmt
=
$this
->
sess
ion
->
getDBH
()
->
query
(
$query
);
$stmt
=
$this
->
connect
ion
->
getDBH
()
->
query
(
$query
);
}
}
$data
=
$stmt
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
$data
=
$stmt
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
$stmt
->
closeCursor
();
$stmt
->
closeCursor
();
...
@@ -944,7 +944,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
...
@@ -944,7 +944,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
*/
*/
final
public
function
getMaxIdentifier
()
{
final
public
function
getMaxIdentifier
()
{
$sql
=
"SELECT MAX("
.
$this
->
getIdentifier
()
.
") FROM "
.
$this
->
getTableName
();
$sql
=
"SELECT MAX("
.
$this
->
getIdentifier
()
.
") FROM "
.
$this
->
getTableName
();
$stmt
=
$this
->
sess
ion
->
getDBH
()
->
query
(
$sql
);
$stmt
=
$this
->
connect
ion
->
getDBH
()
->
query
(
$sql
);
$data
=
$stmt
->
fetch
(
PDO
::
FETCH_NUM
);
$data
=
$stmt
->
fetch
(
PDO
::
FETCH_NUM
);
return
isset
(
$data
[
0
])
?
$data
[
0
]
:
1
;
return
isset
(
$data
[
0
])
?
$data
[
0
]
:
1
;
}
}
...
...
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