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
b6dcef0e
Commit
b6dcef0e
authored
May 24, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
2ce1c5f4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
16 deletions
+49
-16
Hydrate.php
lib/Doctrine/Hydrate.php
+41
-8
Query.php
lib/Doctrine/Query.php
+7
-7
RawSql.php
lib/Doctrine/RawSql.php
+1
-1
No files found.
lib/Doctrine/Hydrate.php
View file @
b6dcef0e
...
...
@@ -189,16 +189,32 @@ class Doctrine_Hydrate
return
$alias
;
}
/**
* getAliases
* returns all aliases
*
* @return array
*/
public
function
getAliases
()
{
return
$this
->
shortAliases
;
}
public
function
addAlias
(
$tableAlias
,
$componentAlias
)
/**
* addTableAlias
* adds an alias for table and associates it with given component alias
*
* @param string $componentAlias the alias for the query component associated with given tableAlias
* @param string $tableAlias the table alias to be added
* @return Doctrine_Hydrate
*/
public
function
addTableAlias
(
$tableAlias
,
$componentAlias
)
{
$this
->
shortAliases
[
$tableAlias
]
=
$componentAlias
;
return
$this
;
}
/**
* get
Short
Alias
* get
Table
Alias
* some database such as Oracle need the identifier lengths to be < ~30 chars
* hence Doctrine creates as short identifier aliases as possible
*
...
...
@@ -209,7 +225,7 @@ class Doctrine_Hydrate
* @param string $tableName the table name from which the table alias is being created
* @return string the generated / fetched short alias
*/
public
function
get
Short
Alias
(
$componentAlias
,
$tableName
=
null
)
public
function
get
Table
Alias
(
$componentAlias
,
$tableName
=
null
)
{
$alias
=
array_search
(
$componentAlias
,
$this
->
shortAliases
);
...
...
@@ -223,17 +239,23 @@ class Doctrine_Hydrate
return
$this
->
generateShortAlias
(
$componentAlias
,
$tableName
);
}
public
function
getTableAlias
(
$componentAlias
)
{
return
$this
->
getShortAlias
(
$componentAlias
);
}
/**
* addQueryPart
* adds a query part in the query part array
*
* @param string $name the name of the query part to be added
* @param string $part query part string
* @throws Doctrine_Hydrate_Exception if trying to add unknown query part
* @return Doctrine_Hydrate this object
*/
public
function
addQueryPart
(
$name
,
$part
)
{
if
(
!
isset
(
$this
->
parts
[
$name
]))
{
throw
new
Doctrine_Hydrate_Exception
(
'Unknown query part '
.
$name
);
}
$this
->
parts
[
$name
][]
=
$part
;
return
$this
;
}
public
function
getDeclaration
(
$name
)
{
...
...
@@ -243,6 +265,15 @@ class Doctrine_Hydrate
return
$this
->
_aliasMap
[
$name
];
}
/**
* setQueryPart
* sets a query part in the query part array
*
* @param string $name the name of the query part to be set
* @param string $part query part string
* @throws Doctrine_Hydrate_Exception if trying to set unknown query part
* @return Doctrine_Hydrate this object
*/
public
function
setQueryPart
(
$name
,
$part
)
{
if
(
!
isset
(
$this
->
parts
[
$name
]))
{
...
...
@@ -254,6 +285,8 @@ class Doctrine_Hydrate
}
else
{
$this
->
parts
[
$name
]
=
$part
;
}
return
$this
;
}
/**
* copyAliases
...
...
lib/Doctrine/Query.php
View file @
b6dcef0e
...
...
@@ -653,7 +653,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
break
;
}
$field
=
$this
->
get
Short
Alias
(
$rootAlias
)
.
'.'
.
$table
->
getIdentifier
();
$field
=
$this
->
get
Table
Alias
(
$rootAlias
)
.
'.'
.
$table
->
getIdentifier
();
// only append the subquery if it actually contains something
if
(
$subquery
!==
''
)
{
...
...
@@ -704,7 +704,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
$componentAlias
=
key
(
$this
->
_aliasMap
);
// get short alias
$alias
=
$this
->
get
Short
Alias
(
$componentAlias
);
$alias
=
$this
->
get
Table
Alias
(
$componentAlias
);
$primaryKey
=
$alias
.
'.'
.
$table
->
getIdentifier
();
// initialize the base of the subquery
...
...
@@ -970,8 +970,8 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
$this
->
needsSubquery
=
true
;
}
$localAlias
=
$this
->
get
Short
Alias
(
$parent
,
$table
->
getTableName
());
$foreignAlias
=
$this
->
get
Short
Alias
(
$componentAlias
,
$relation
->
getTable
()
->
getTableName
());
$localAlias
=
$this
->
get
Table
Alias
(
$parent
,
$table
->
getTableName
());
$foreignAlias
=
$this
->
get
Table
Alias
(
$componentAlias
,
$relation
->
getTable
()
->
getTableName
());
$localSql
=
$this
->
_conn
->
quoteIdentifier
(
$table
->
getTableName
())
.
' '
.
$localAlias
;
$foreignSql
=
$this
->
_conn
->
quoteIdentifier
(
$relation
->
getTable
()
->
getTableName
())
.
' '
.
$foreignAlias
;
...
...
@@ -992,7 +992,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
$assocPath
=
$prevPath
.
'.'
.
$asf
->
getComponentName
();
$assocAlias
=
$this
->
get
Short
Alias
(
$assocPath
,
$asf
->
getTableName
());
$assocAlias
=
$this
->
get
Table
Alias
(
$assocPath
,
$asf
->
getTableName
());
$queryPart
=
$join
.
$assocTableName
.
' '
.
$assocAlias
.
' ON '
.
$localAlias
.
'.'
.
$table
->
getIdentifier
()
.
' = '
...
...
@@ -1070,7 +1070,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
$tableName
=
$table
->
getTableName
();
// get the short alias for this table
$tableAlias
=
$this
->
get
Short
Alias
(
$componentAlias
,
$tableName
);
$tableAlias
=
$this
->
get
Table
Alias
(
$componentAlias
,
$tableName
);
// quote table name
$queryPart
=
$this
->
_conn
->
quoteIdentifier
(
$tableName
);
...
...
@@ -1115,7 +1115,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
$table
=
$map
[
'table'
];
// build the query base
$q
=
'SELECT COUNT(DISTINCT '
.
$this
->
get
Short
Alias
(
$table
->
getTableName
())
$q
=
'SELECT COUNT(DISTINCT '
.
$this
->
get
Table
Alias
(
$table
->
getTableName
())
.
'.'
.
$table
->
getIdentifier
()
.
') FROM '
.
$this
->
buildFromPart
();
...
...
lib/Doctrine/RawSql.php
View file @
b6dcef0e
...
...
@@ -257,7 +257,7 @@ class Doctrine_RawSql extends Doctrine_Query_Abstract
'parent'
=>
$parent
,
'relation'
=>
$relation
);
}
$this
->
addAlias
(
$tableAlias
,
$componentAlias
);
$this
->
add
Table
Alias
(
$tableAlias
,
$componentAlias
);
$parent
=
$currPath
;
}
...
...
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