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
91ffb084
Commit
91ffb084
authored
Jul 22, 2006
by
doctrine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[amadeus] added getFirst() method
parent
f6fa905e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
20 deletions
+26
-20
Collection.php
Doctrine/Collection.php
+26
-20
No files found.
Doctrine/Collection.php
View file @
91ffb084
...
@@ -32,7 +32,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
...
@@ -32,7 +32,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
/**
/**
* @var boolean $expandable whether or not this collection has been expanded
* @var boolean $expandable whether or not this collection has been expanded
*/
*/
protected
$expandable
=
true
;
protected
$expandable
=
true
;
/**
/**
* @var array $expanded
* @var array $expanded
*/
*/
...
@@ -51,7 +51,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
...
@@ -51,7 +51,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
*/
*/
public
function
__construct
(
Doctrine_Table
$table
)
{
public
function
__construct
(
Doctrine_Table
$table
)
{
$this
->
table
=
$table
;
$this
->
table
=
$table
;
$name
=
$table
->
getAttribute
(
Doctrine
::
ATTR_COLL_KEY
);
$name
=
$table
->
getAttribute
(
Doctrine
::
ATTR_COLL_KEY
);
if
(
$name
!==
null
)
{
if
(
$name
!==
null
)
{
$this
->
generator
=
new
Doctrine_IndexGenerator
(
$name
);
$this
->
generator
=
new
Doctrine_IndexGenerator
(
$name
);
...
@@ -85,7 +85,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
...
@@ -85,7 +85,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
unset
(
$vars
[
'generator'
]);
unset
(
$vars
[
'generator'
]);
$vars
[
'table'
]
=
$vars
[
'table'
]
->
getComponentName
();
$vars
[
'table'
]
=
$vars
[
'table'
]
->
getComponentName
();
return
serialize
(
$vars
);
return
serialize
(
$vars
);
}
}
/**
/**
...
@@ -97,13 +97,13 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
...
@@ -97,13 +97,13 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
public
function
unserialize
(
$serialized
)
{
public
function
unserialize
(
$serialized
)
{
$manager
=
Doctrine_Manager
::
getInstance
();
$manager
=
Doctrine_Manager
::
getInstance
();
$session
=
$manager
->
getCurrentSession
();
$session
=
$manager
->
getCurrentSession
();
$array
=
unserialize
(
$serialized
);
$array
=
unserialize
(
$serialized
);
foreach
(
$array
as
$name
=>
$values
)
{
foreach
(
$array
as
$name
=>
$values
)
{
$this
->
$name
=
$values
;
$this
->
$name
=
$values
;
}
}
$this
->
table
=
$session
->
getTable
(
$this
->
table
);
$this
->
table
=
$session
->
getTable
(
$this
->
table
);
$this
->
expanded
=
array
();
$this
->
expanded
=
array
();
...
@@ -141,7 +141,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
...
@@ -141,7 +141,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
public
function
getGenerator
()
{
public
function
getGenerator
()
{
return
$this
->
generator
;
return
$this
->
generator
;
}
}
/**
/**
* @return array
* @return array
*/
*/
public
function
getData
()
{
public
function
getData
()
{
...
@@ -153,6 +153,12 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
...
@@ -153,6 +153,12 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
public
function
addData
(
array
$data
)
{
public
function
addData
(
array
$data
)
{
$this
->
data
[]
=
$data
;
$this
->
data
[]
=
$data
;
}
}
/**
* @return mixed
*/
public
function
getFirst
()
{
return
$this
->
data
[
0
];
}
/**
/**
* @return mixed
* @return mixed
*/
*/
...
@@ -168,7 +174,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
...
@@ -168,7 +174,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
if
(
$relation
instanceof
Doctrine_ForeignKey
||
if
(
$relation
instanceof
Doctrine_ForeignKey
||
$relation
instanceof
Doctrine_LocalKey
)
{
$relation
instanceof
Doctrine_LocalKey
)
{
$this
->
reference_field
=
$relation
->
getForeign
();
$this
->
reference_field
=
$relation
->
getForeign
();
$value
=
$record
->
get
(
$relation
->
getLocal
());
$value
=
$record
->
get
(
$relation
->
getLocal
());
...
@@ -206,10 +212,10 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
...
@@ -206,10 +212,10 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
if
(
!
$this
->
expandable
&&
isset
(
$this
->
expanded
[
$offset
]))
if
(
!
$this
->
expandable
&&
isset
(
$this
->
expanded
[
$offset
]))
return
false
;
return
false
;
$fields
=
implode
(
", "
,
$this
->
table
->
getColumnNames
());
$fields
=
implode
(
", "
,
$this
->
table
->
getColumnNames
());
break
;
break
;
default
:
default
:
if
(
!
$this
->
expandable
)
if
(
!
$this
->
expandable
)
return
false
;
return
false
;
...
@@ -239,7 +245,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
...
@@ -239,7 +245,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
if
(
!
isset
(
$offset
))
{
if
(
!
isset
(
$offset
))
{
$ids
=
$this
->
getPrimaryKeys
();
$ids
=
$this
->
getPrimaryKeys
();
if
(
!
empty
(
$ids
))
{
if
(
!
empty
(
$ids
))
{
$where
[]
=
$this
->
table
->
getIdentifier
()
.
" NOT IN ("
.
substr
(
str_repeat
(
"?, "
,
count
(
$ids
)),
0
,
-
2
)
.
")"
;
$where
[]
=
$this
->
table
->
getIdentifier
()
.
" NOT IN ("
.
substr
(
str_repeat
(
"?, "
,
count
(
$ids
)),
0
,
-
2
)
.
")"
;
$params
=
array_merge
(
$params
,
$ids
);
$params
=
array_merge
(
$params
,
$ids
);
...
@@ -250,20 +256,20 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
...
@@ -250,20 +256,20 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
}
elseif
(
$this
->
relation
instanceof
Doctrine_Association
)
{
}
elseif
(
$this
->
relation
instanceof
Doctrine_Association
)
{
$asf
=
$this
->
relation
->
getAssociationFactory
();
$asf
=
$this
->
relation
->
getAssociationFactory
();
$query
=
"SELECT "
.
$foreign
.
" FROM "
.
$asf
->
getTableName
()
.
" WHERE "
.
$local
.
"="
.
$this
->
getIncremented
();
$query
=
"SELECT "
.
$foreign
.
" FROM "
.
$asf
->
getTableName
()
.
" WHERE "
.
$local
.
"="
.
$this
->
getIncremented
();
$table
=
$fk
->
getTable
();
$table
=
$fk
->
getTable
();
$graph
=
new
Doctrine_DQL_Parser
(
$table
->
getSession
());
$graph
=
new
Doctrine_DQL_Parser
(
$table
->
getSession
());
$q
=
"FROM "
.
$table
->
getComponentName
()
.
" WHERE "
.
$table
->
getComponentName
()
.
"."
.
$table
->
getIdentifier
()
.
" IN (
$query
)"
;
$q
=
"FROM "
.
$table
->
getComponentName
()
.
" WHERE "
.
$table
->
getComponentName
()
.
"."
.
$table
->
getIdentifier
()
.
" IN (
$query
)"
;
}
}
}
}
$query
=
"SELECT "
.
$fields
.
" FROM "
.
$this
->
table
->
getTableName
();
$query
=
"SELECT "
.
$fields
.
" FROM "
.
$this
->
table
->
getTableName
();
// apply column aggregation inheritance
// apply column aggregation inheritance
foreach
(
$this
->
table
->
getInheritanceMap
()
as
$k
=>
$v
)
{
foreach
(
$this
->
table
->
getInheritanceMap
()
as
$k
=>
$v
)
{
$where
[]
=
$k
.
" = ?"
;
$where
[]
=
$k
.
" = ?"
;
...
@@ -290,7 +296,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
...
@@ -290,7 +296,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
$this
->
reference
->
addReference
(
$record
,
$this
->
relation
,
$i
);
$this
->
reference
->
addReference
(
$record
,
$this
->
relation
,
$i
);
}
else
}
else
$this
->
data
[
$i
]
=
$record
;
$this
->
data
[
$i
]
=
$record
;
$i
++
;
$i
++
;
}
}
...
@@ -316,7 +322,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
...
@@ -316,7 +322,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
}
}
$removed
=
$this
->
data
[
$key
];
$removed
=
$this
->
data
[
$key
];
unset
(
$this
->
data
[
$key
]);
unset
(
$this
->
data
[
$key
]);
return
$removed
;
return
$removed
;
}
}
...
@@ -386,7 +392,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
...
@@ -386,7 +392,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
return
count
(
$this
->
data
);
return
count
(
$this
->
data
);
}
}
/**
/**
* set
* set
* @param integer $key
* @param integer $key
* @param Doctrine_Record $record
* @param Doctrine_Record $record
* @return void
* @return void
...
@@ -432,7 +438,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
...
@@ -432,7 +438,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
* populate
* populate
*
*
* @param Doctrine_Query $query
* @param Doctrine_Query $query
* @param integer $key
* @param integer $key
*/
*/
public
function
populate
(
Doctrine_Hydrate
$query
)
{
public
function
populate
(
Doctrine_Hydrate
$query
)
{
$name
=
$this
->
table
->
getComponentName
();
$name
=
$this
->
table
->
getComponentName
();
...
@@ -457,7 +463,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
...
@@ -457,7 +463,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
$this
->
data
[
$i
]
=
$record
;
$this
->
data
[
$i
]
=
$record
;
unset
(
$this
->
data
[
$k
]);
unset
(
$this
->
data
[
$k
]);
}
}
}
}
}
}
}
}
/**
/**
...
...
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