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
be5eb98e
Commit
be5eb98e
authored
Sep 20, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
2f70b203
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
51 additions
and
69 deletions
+51
-69
UnitOfWork.php
lib/Doctrine/Connection/UnitOfWork.php
+9
-2
Query.php
lib/Doctrine/Query.php
+4
-3
Select.php
lib/Doctrine/Query/Select.php
+0
-2
Set.php
lib/Doctrine/Query/Set.php
+16
-11
Where.php
lib/Doctrine/Query/Where.php
+2
-1
RawSql.php
lib/Doctrine/RawSql.php
+1
-1
Record.php
lib/Doctrine/Record.php
+1
-1
Table.php
lib/Doctrine/Table.php
+17
-47
Unique.php
lib/Doctrine/Validator/Unique.php
+1
-1
No files found.
lib/Doctrine/Connection/UnitOfWork.php
View file @
be5eb98e
...
...
@@ -388,6 +388,13 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
if
(
$obj
instanceof
Doctrine_Record
&&
$obj
->
isModified
())
{
$obj
->
save
(
$this
->
conn
);
/**
$id = array_values($obj->identifier());
foreach ((array) $rel->getLocal() as $k => $field) {
$record->set($field, $id[$k]);
}
*/
}
}
}
...
...
@@ -538,7 +545,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
$sql
=
'UPDATE '
.
$this
->
conn
->
quoteIdentifier
(
$record
->
getTable
()
->
getTableName
())
.
' SET '
.
implode
(
', '
,
$set
)
.
' WHERE '
.
implode
(
' = ? AND '
,
$record
->
getTable
()
->
getPrimaryKeys
())
.
' WHERE '
.
implode
(
' = ? AND '
,
(
array
)
$record
->
getTable
()
->
getIdentifier
())
.
' = ?'
;
$stmt
=
$this
->
conn
->
prepare
(
$sql
);
...
...
@@ -575,7 +582,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
return
false
;
}
$table
=
$record
->
getTable
();
$keys
=
$table
->
getPrimaryKeys
();
$keys
=
(
array
)
$table
->
getIdentifier
();
$seq
=
$record
->
getTable
()
->
sequenceName
;
...
...
lib/Doctrine/Query.php
View file @
be5eb98e
...
...
@@ -375,7 +375,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
// only auto-add the primary key fields if this query object is not
// a subquery of another query object
if
(
!
$this
->
isSubquery
)
{
$fields
=
array_unique
(
array_merge
(
$table
->
getPrimaryKeys
(),
$fields
));
$fields
=
array_unique
(
array_merge
(
(
array
)
$table
->
getIdentifier
(),
$fields
));
}
}
$sql
=
array
();
...
...
@@ -1243,8 +1243,9 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
case
'by'
:
continue
;
default
:
if
(
!
isset
(
$p
))
if
(
!
isset
(
$p
))
{
throw
new
Doctrine_Query_Exception
(
"Couldn't parse query."
);
}
$parts
[
$p
][]
=
$part
;
}
...
...
@@ -1267,7 +1268,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
if
(
$clear
)
{
$this
->
clear
();
}
$query
=
trim
(
$query
);
$query
=
str_replace
(
"
\n
"
,
' '
,
$query
);
$query
=
str_replace
(
"
\r
"
,
' '
,
$query
);
...
...
lib/Doctrine/Query/Select.php
View file @
be5eb98e
...
...
@@ -35,7 +35,5 @@ class Doctrine_Query_Select extends Doctrine_Query_Part
public
function
parse
(
$dql
)
{
$this
->
query
->
parseSelect
(
$dql
);
return
null
;
}
}
lib/Doctrine/Query/Set.php
View file @
be5eb98e
...
...
@@ -34,19 +34,24 @@ class Doctrine_Query_Set extends Doctrine_Query_Part
{
public
function
parse
(
$dql
)
{
preg_match_all
(
"/[a-z0-9_]+\.[a-z0-9_]+[\.[a-z0-9]+]*/i"
,
$dql
,
$m
);
$terms
=
Doctrine_Tokenizer
::
sqlExplode
(
$dql
,
' '
);
foreach
(
$terms
as
$term
)
{
if
(
isset
(
$m
[
0
]))
{
foreach
(
$m
[
0
]
as
$part
)
{
$e
=
explode
(
'.'
,
trim
(
$part
));
$field
=
array_pop
(
$e
);
preg_match_all
(
"/[a-z0-9_]+\.[a-z0-9_]+[\.[a-z0-9]+]*/i"
,
$term
,
$m
);
$reference
=
implode
(
'.'
,
$e
);
$alias
=
$this
->
query
->
getTableAlias
(
$reference
);
$map
=
$this
->
query
->
getAliasDeclaration
(
$reference
);
$dql
=
str_replace
(
$part
,
$map
[
'table'
]
->
getColumnName
(
$field
),
$dql
);
if
(
isset
(
$m
[
0
]))
{
foreach
(
$m
[
0
]
as
$part
)
{
$e
=
explode
(
'.'
,
trim
(
$part
));
$field
=
array_pop
(
$e
);
$reference
=
implode
(
'.'
,
$e
);
$alias
=
$this
->
query
->
getTableAlias
(
$reference
);
$map
=
$this
->
query
->
getAliasDeclaration
(
$reference
);
$dql
=
str_replace
(
$part
,
$map
[
'table'
]
->
getColumnName
(
$field
),
$dql
);
}
}
}
...
...
lib/Doctrine/Query/Where.php
View file @
be5eb98e
...
...
@@ -68,7 +68,7 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition
$map
=
$this
->
query
->
getRootDeclaration
();
$alias
=
$this
->
query
->
getTableAlias
(
$this
->
query
->
getRootAlias
());
$table
=
$map
[
'table'
];
$table
=
$map
[
'table'
];
}
else
{
$map
=
$this
->
query
->
load
(
$reference
,
false
);
...
...
@@ -127,6 +127,7 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition
$value
[]
=
$this
->
parseLiteralValue
(
$part
);
}
}
$value
=
'('
.
implode
(
', '
,
$value
)
.
')'
;
}
}
elseif
(
substr
(
$value
,
0
,
1
)
==
':'
||
$value
===
'?'
)
{
...
...
lib/Doctrine/RawSql.php
View file @
be5eb98e
...
...
@@ -164,7 +164,7 @@ class Doctrine_RawSql extends Doctrine_Query_Abstract
foreach
(
$this
->
getTableAliases
()
as
$tableAlias
=>
$componentAlias
)
{
$map
=
$this
->
_aliasMap
[
$componentAlias
];
foreach
(
$map
[
'table'
]
->
getPrimaryKeys
()
as
$key
)
{
foreach
(
(
array
)
$map
[
'table'
]
->
getIdentifier
()
as
$key
)
{
$field
=
$tableAlias
.
'.'
.
$key
;
if
(
!
isset
(
$this
->
parts
[
'select'
][
$field
]))
{
...
...
lib/Doctrine/Record.php
View file @
be5eb98e
...
...
@@ -148,7 +148,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
self
::
$_index
++
;
$keys
=
$this
->
_table
->
getPrimaryKeys
();
$keys
=
(
array
)
$this
->
_table
->
getIdentifier
();
// get the data array
$this
->
_data
=
$this
->
_table
->
getData
();
...
...
lib/Doctrine/Table.php
View file @
be5eb98e
...
...
@@ -53,7 +53,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
/**
* @var Doctrine_Connection $conn Doctrine_Connection object that created this table
*/
private
$conn
;
private
$
_
conn
;
/**
* @var array $identityMap first level cache
*/
...
...
@@ -169,9 +169,9 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
*/
public
function
__construct
(
$name
,
Doctrine_Connection
$conn
)
{
$this
->
conn
=
$conn
;
$this
->
_
conn
=
$conn
;
$this
->
setParent
(
$this
->
conn
);
$this
->
setParent
(
$this
->
_
conn
);
$this
->
options
[
'name'
]
=
$name
;
$this
->
_parser
=
new
Doctrine_Relation_Parser
(
$this
);
...
...
@@ -271,7 +271,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
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
;
...
...
@@ -315,7 +315,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
*/
public
function
export
()
{
$this
->
conn
->
export
->
exportTable
(
$this
);
$this
->
_
conn
->
export
->
exportTable
(
$this
);
}
/**
* getExportableFormat
...
...
@@ -413,14 +413,14 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
public
function
exportConstraints
()
{
try
{
$this
->
conn
->
beginTransaction
();
$this
->
_
conn
->
beginTransaction
();
foreach
(
$this
->
options
[
'index'
]
as
$index
=>
$definition
)
{
$this
->
conn
->
export
->
createIndex
(
$this
->
options
[
'tableName'
],
$index
,
$definition
);
$this
->
_
conn
->
export
->
createIndex
(
$this
->
options
[
'tableName'
],
$index
,
$definition
);
}
$this
->
conn
->
commit
();
$this
->
_
conn
->
commit
();
}
catch
(
Doctrine_Connection_Exception
$e
)
{
$this
->
conn
->
rollback
();
$this
->
_
conn
->
rollback
();
throw
$e
;
}
...
...
@@ -799,42 +799,12 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
{
return
isset
(
$this
->
columns
[
$name
]);
}
/**
* @param mixed $key
* @return void
*/
public
function
setPrimaryKey
(
$key
)
{
switch
(
gettype
(
$key
))
{
case
"array"
:
$this
->
primaryKeys
=
array_values
(
$key
);
break
;
case
"string"
:
$this
->
primaryKeys
[]
=
$key
;
break
;
};
}
/**
* returns all primary keys
* @return array
*/
public
function
getPrimaryKeys
()
{
return
$this
->
primaryKeys
;
}
/**
* @return boolean
*/
public
function
hasPrimaryKey
(
$key
)
{
return
in_array
(
$key
,
$this
->
primaryKeys
);
}
/**
* @return Doctrine_Connection
*/
public
function
getConnection
()
{
return
$this
->
conn
;
return
$this
->
_
conn
;
}
/**
* create
...
...
@@ -894,7 +864,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
*/
public
function
findAll
(
$hydrationMode
=
null
)
{
$graph
=
new
Doctrine_Query
(
$this
->
conn
);
$graph
=
new
Doctrine_Query
(
$this
->
_
conn
);
$users
=
$graph
->
query
(
'FROM '
.
$this
->
options
[
'name'
],
array
(),
$hydrationMode
);
return
$users
;
}
...
...
@@ -909,7 +879,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
* @return Doctrine_Collection
*/
public
function
findBySql
(
$dql
,
array
$params
=
array
(),
$hydrationMode
=
null
)
{
$q
=
new
Doctrine_Query
(
$this
->
conn
);
$q
=
new
Doctrine_Query
(
$this
->
_
conn
);
$users
=
$q
->
query
(
'FROM '
.
$this
->
options
[
'name'
]
.
' WHERE '
.
$dql
,
$params
,
$hydrationMode
);
return
$users
;
}
...
...
@@ -1023,7 +993,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
return
$this
->
options
[
'name'
];
}
foreach
(
$this
->
options
[
'subclasses'
]
as
$subclass
)
{
$table
=
$this
->
conn
->
getTable
(
$subclass
);
$table
=
$this
->
_
conn
->
getTable
(
$subclass
);
$inheritanceMap
=
$table
->
getOption
(
'inheritanceMap'
);
$nomatch
=
false
;
foreach
(
$inheritanceMap
as
$key
=>
$value
)
{
...
...
@@ -1053,7 +1023,7 @@ 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
)
return
false
;
...
...
@@ -1067,7 +1037,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
*/
public
function
count
()
{
$a
=
$this
->
conn
->
execute
(
'SELECT COUNT(1) FROM '
.
$this
->
options
[
'tableName'
])
->
fetch
(
Doctrine
::
FETCH_NUM
);
$a
=
$this
->
_
conn
->
execute
(
'SELECT COUNT(1) FROM '
.
$this
->
options
[
'tableName'
])
->
fetch
(
Doctrine
::
FETCH_NUM
);
return
current
(
$a
);
}
/**
...
...
@@ -1104,7 +1074,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
return
$index
;
}
if
(
!
$this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_USE_NATIVE_ENUM
)
if
(
!
$this
->
_
conn
->
getAttribute
(
Doctrine
::
ATTR_USE_NATIVE_ENUM
)
&&
isset
(
$this
->
columns
[
$field
][
'values'
][
$index
])
)
{
return
$this
->
columns
[
$field
][
'values'
][
$index
];
...
...
@@ -1124,7 +1094,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
$values
=
$this
->
getEnumValues
(
$field
);
$index
=
array_search
(
$value
,
$values
);
if
(
$index
===
false
||
!
$this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_USE_NATIVE_ENUM
))
{
if
(
$index
===
false
||
!
$this
->
_
conn
->
getAttribute
(
Doctrine
::
ATTR_USE_NATIVE_ENUM
))
{
return
$index
;
}
return
$value
;
...
...
lib/Doctrine/Validator/Unique.php
View file @
be5eb98e
...
...
@@ -57,7 +57,7 @@ class Doctrine_Validator_Unique
// as the one that is validated here.
$state
=
$this
->
invoker
->
state
();
if
(
!
(
$state
==
Doctrine_Record
::
STATE_TDIRTY
||
$state
==
Doctrine_Record
::
STATE_TCLEAN
))
{
foreach
(
$table
->
getPrimaryKeys
()
as
$pk
)
{
foreach
(
(
array
)
$table
->
getIdentifier
()
as
$pk
)
{
$sql
.=
" AND
{
$pk
}
!= ?"
;
$values
[]
=
$this
->
invoker
->
$pk
;
}
...
...
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