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
09ca6e46
Commit
09ca6e46
authored
May 09, 2006
by
doctrine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New component Doctrine_Query (replaces Doctrine_DQL_Parser)
parent
d07dfbd7
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
75 additions
and
63 deletions
+75
-63
Collection.class.php
classes/Collection.class.php
+4
-4
Manager.class.php
classes/Manager.class.php
+18
-7
Record.class.php
classes/Record.class.php
+6
-12
Session.class.php
classes/Session.class.php
+24
-11
Common.class.php
classes/Session/Common.class.php
+4
-4
Table.class.php
classes/Table.class.php
+14
-13
BatchIteratorTestCase.class.php
tests/BatchIteratorTestCase.class.php
+1
-1
run.php
tests/run.php
+4
-11
No files found.
classes/Collection.class.php
View file @
09ca6e46
...
...
@@ -365,16 +365,16 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
return
true
;
}
/**
* @param Doctrine_
DQL_Parser $graph
* @param Doctrine_
Query $query
* @param integer $key
*/
public
function
populate
(
Doctrine_
DQL_Parser
$graph
)
{
public
function
populate
(
Doctrine_
Query
$query
)
{
$name
=
$this
->
table
->
getComponentName
();
if
(
$this
instanceof
Doctrine_Collection_Immediate
||
$this
instanceof
Doctrine_Collection_Offset
)
{
$data
=
$
graph
->
getData
(
$name
);
$data
=
$
query
->
getData
(
$name
);
if
(
is_array
(
$data
))
{
foreach
(
$data
as
$k
=>
$v
)
:
$this
->
table
->
setData
(
$v
);
...
...
@@ -382,7 +382,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
endforeach
;
}
}
elseif
(
$this
instanceof
Doctrine_Collection_Batch
)
{
$this
->
data
=
$
graph
->
getData
(
$name
);
$this
->
data
=
$
query
->
getData
(
$name
);
if
(
isset
(
$this
->
generator
))
{
foreach
(
$this
->
data
as
$k
=>
$v
)
{
...
...
classes/Manager.class.php
View file @
09ca6e46
...
...
@@ -16,15 +16,15 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
*/
private
$sessions
=
array
();
/**
* @var integer $index
* @var integer $index
the incremented index
*/
private
$index
=
0
;
/**
* @var integer $currIndex
* @var integer $currIndex
the current session index
*/
private
$currIndex
=
0
;
/**
* @var string $root
* @var string $root
root directory
*/
private
$root
;
...
...
@@ -36,6 +36,9 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
}
/**
* setDefaultAttributes
* sets default attributes
*
* @return boolean
*/
final
public
function
setDefaultAttributes
()
{
static
$init
=
false
;
...
...
@@ -61,7 +64,9 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
if
(
$old
===
null
)
$this
->
setAttribute
(
$attribute
,
$value
);
}
return
true
;
}
return
false
;
}
/**
* returns the root directory of Doctrine
...
...
@@ -78,7 +83,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
final
public
static
function
getInstance
()
{
static
$instance
;
if
(
!
isset
(
$instance
))
$instance
=
new
Doctrine_Manager
();
$instance
=
new
self
();
return
$instance
;
}
...
...
@@ -157,6 +162,8 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
}
/**
* getSessions
* returns all opened sessions
*
* @return array
*/
final
public
function
getSessions
()
{
...
...
@@ -177,14 +184,17 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
}
/**
* count
* @return integer the number of open sessions
* returns the number of opened sessions
*
* @return integer
*/
public
function
count
()
{
return
count
(
$this
->
sessions
);
}
/**
* getIterator
* returns an ArrayIterator that iterates through open sessions
* returns an ArrayIterator that iterates through all sessions
*
* @return ArrayIterator
*/
public
function
getIterator
()
{
...
...
@@ -193,6 +203,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
/**
* getCurrentSession
* returns the current session
*
* @throws Doctrine_Session_Exception if there are no open sessions
* @return Doctrine_Session
*/
...
...
classes/Record.class.php
View file @
09ca6e46
...
...
@@ -372,11 +372,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
if
(
is_array
(
$this
->
data
[
$name
]))
{
// no use trying to load the data from database if the Doctrine_Record is not a proxy
if
(
$this
->
state
!=
Doctrine_Record
::
STATE_TDIRTY
&&
$this
->
state
!=
Doctrine_Record
::
STATE_TCLEAN
&&
$this
->
state
!=
Doctrine_Record
::
STATE_CLEAN
&&
$this
->
state
!=
Doctrine_Record
::
STATE_DIRTY
)
{
if
(
$this
->
state
==
Doctrine_Record
::
STATE_PROXY
)
{
if
(
!
empty
(
$this
->
collections
))
{
foreach
(
$this
->
collections
as
$collection
)
{
$collection
->
load
(
$this
);
...
...
@@ -501,7 +497,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
endswitch
;
}
elseif
(
$fk
instanceof
Doctrine_Association
)
{
//
many-to-many
relation found
//
join table
relation found
if
(
!
(
$value
instanceof
Doctrine_Collection
))
throw
new
Doctrine_Exception
(
"Couldn't call Doctrine::set(), second argument should be an instance of Doctrine_Collection when setting one-to-many references."
);
}
...
...
@@ -822,7 +818,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$name
=
$table
->
getComponentName
();
$local
=
$fk
->
getLocal
();
$foreign
=
$fk
->
getForeign
();
$graph
=
$table
->
get
DQLParser
();
$graph
=
$table
->
get
QueryObject
();
$type
=
$fk
->
getType
();
switch
(
$this
->
getState
())
:
...
...
@@ -896,12 +892,10 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this
->
originals
[
$name
]
=
clone
$coll
;
}
elseif
(
$fk
instanceof
Doctrine_Association
)
{
$asf
=
$fk
->
getAssociationFactory
();
$query
=
"SELECT "
.
$foreign
.
" FROM "
.
$asf
->
getTableName
()
.
" WHERE "
.
$local
.
" = ?"
;
$graph
=
new
Doctrine_
DQL_Parser
(
$table
->
getSession
());
$graph
=
new
Doctrine_
Query
(
$table
->
getSession
());
$query
=
"FROM "
.
$table
->
getComponentName
()
.
" WHERE "
.
$table
->
getComponentName
()
.
"."
.
$table
->
getIdentifier
()
.
" IN (
$query
)"
;
$coll
=
$graph
->
query
(
$query
,
array
(
$this
->
getID
()));
...
...
classes/Session.class.php
View file @
09ca6e46
...
...
@@ -2,7 +2,8 @@
require_once
(
"Configurable.class.php"
);
require_once
(
"Record.class.php"
);
/**
* @author Konsta Vesterinen
* Doctrine_Session
*
* @package Doctrine ORM
* @url www.phpdoctrine.com
* @license LGPL
...
...
@@ -103,19 +104,26 @@ abstract class Doctrine_Session extends Doctrine_Configurable implements Countab
return
$this
->
cacheHandler
;
}
/**
* returns the state of this session
*
* @see Doctrine_Session::STATE_* constants
* @return integer the session state
*/
public
function
getState
()
{
return
$this
->
state
;
}
/**
* returns the manager that created this session
*
* @return Doctrine_Manager
*/
public
function
getManager
()
{
return
$this
->
getParent
();
}
/**
* @return object PDO the database handle
* returns the database handler of which this session uses
*
* @return object PDO the database handler
*/
public
function
getDBH
()
{
return
$this
->
dbh
;
...
...
@@ -125,7 +133,7 @@ abstract class Doctrine_Session extends Doctrine_Configurable implements Countab
* queries the database with Doctrine Query Language
*/
final
public
function
query
(
$query
,
array
$params
=
array
())
{
$parser
=
new
Doctrine_
DQL_Parser
(
$this
);
$parser
=
new
Doctrine_
Query
(
$this
);
return
$parser
->
query
(
$query
,
$params
);
}
...
...
@@ -145,7 +153,10 @@ abstract class Doctrine_Session extends Doctrine_Configurable implements Countab
return
$this
->
dbh
->
query
(
$query
);
}
/**
* @return object PDOStatement -- the PDOStatement object
* @param string $query sql query
* @param array $params query parameters
*
* @return PDOStatement
*/
public
function
execute
(
$query
,
array
$params
=
array
())
{
if
(
!
empty
(
$params
))
{
...
...
@@ -157,7 +168,9 @@ abstract class Doctrine_Session extends Doctrine_Configurable implements Countab
}
}
/**
* @param $mixed -- Doctrine_Table name
* whether or not this session has table $name initialized
*
* @param $mixed $name
* @return boolean
*/
public
function
hasTable
(
$name
)
{
...
...
classes/Session/Common.class.php
View file @
09ca6e46
...
...
@@ -3,12 +3,12 @@
* standard session, the parent of pgsql, mysql and sqlite
*/
class
Doctrine_Session_Common
extends
Doctrine_Session
{
public
function
modifyLimitQuery
(
$query
,
$limit
=
null
,
$offset
=
null
)
{
if
(
isset
(
$limit
)
&&
isset
(
$offset
)
)
{
public
function
modifyLimitQuery
(
$query
,
$limit
=
false
,
$offset
=
false
)
{
if
(
$limit
&&
$offset
)
{
$query
.=
" LIMIT "
.
$limit
.
" OFFSET "
.
$offset
;
}
elseif
(
isset
(
$limit
)
&&
!
isset
(
$offset
)
)
{
}
elseif
(
$limit
&&
!
$offset
)
{
$query
.=
" LIMIT "
.
$limit
;
}
elseif
(
!
isset
(
$limit
)
&&
isset
(
$offset
)
)
{
}
elseif
(
!
$limit
&&
$offset
)
{
$query
.=
" LIMIT 999999999999 OFFSET "
.
$offset
;
}
...
...
classes/Table.class.php
View file @
09ca6e46
...
...
@@ -68,7 +68,7 @@ class Doctrine_Table extends Doctrine_Configurable {
*/
private
$cache
;
/**
* @var
Doctrine_Table_Description $description columns object for this table
* @var
array $columns an array of column definitions
*/
private
$columns
;
/**
...
...
@@ -96,8 +96,6 @@ class Doctrine_Table extends Doctrine_Configurable {
$this
->
setParent
(
$this
->
session
);
$name
=
ucwords
(
strtolower
(
$name
));
$this
->
name
=
$name
;
if
(
!
class_exists
(
$name
)
||
empty
(
$name
))
...
...
@@ -340,12 +338,12 @@ class Doctrine_Table extends Doctrine_Configurable {
}
/**
* @param string $objTableName
* @param string $f
kF
ield
* @param string $field
* @return void
*/
final
public
function
bind
(
$objTableName
,
$f
kF
ield
,
$type
,
$localKey
)
{
final
public
function
bind
(
$objTableName
,
$field
,
$type
,
$localKey
)
{
$name
=
(
string
)
$objTableName
;
$field
=
(
string
)
$f
kF
ield
;
$field
=
(
string
)
$field
;
if
(
isset
(
$this
->
foreignKeys
[
$name
]))
throw
new
InvalidKeyException
();
...
...
@@ -387,7 +385,7 @@ class Doctrine_Table extends Doctrine_Configurable {
}
/**
* @param string $name component name of which a foreign key object is bound
* @return Doctrine_
ForeignKey
* @return Doctrine_
Relation
*/
final
public
function
getForeignKey
(
$name
)
{
if
(
isset
(
$this
->
foreignKeys
[
$name
]))
...
...
@@ -540,7 +538,7 @@ class Doctrine_Table extends Doctrine_Configurable {
* @return Doctrine_Collection a collection of all data access objects
*/
public
function
findAll
()
{
$graph
=
new
Doctrine_
DQL_Parser
(
$this
->
session
);
$graph
=
new
Doctrine_
Query
(
$this
->
session
);
$users
=
$graph
->
query
(
"FROM "
.
$this
->
name
);
return
$users
;
}
...
...
@@ -549,7 +547,7 @@ class Doctrine_Table extends Doctrine_Configurable {
* @return Doctrine_Collection a collection of data access objects
*/
public
function
findBySql
(
$sql
,
array
$params
=
array
())
{
$graph
=
new
Doctrine_
DQL_Parser
(
$this
->
session
);
$graph
=
new
Doctrine_
Query
(
$this
->
session
);
$users
=
$graph
->
query
(
"FROM "
.
$this
->
name
.
" WHERE "
.
$sql
,
$params
);
return
$users
;
}
...
...
@@ -587,16 +585,19 @@ class Doctrine_Table extends Doctrine_Configurable {
return
$this
->
columns
;
}
/**
* @param integer $fetchMode
* @return Doctrine_DQL_Parser a Doctrine_DQL_Parser object
* @return Doctrine_Query a Doctrine_Query object
*/
public
function
get
DQLParser
()
{
$graph
=
new
Doctrine_
DQL_Parser
(
$this
->
getSession
());
public
function
get
QueryObject
()
{
$graph
=
new
Doctrine_
Query
(
$this
->
getSession
());
$graph
->
load
(
$this
->
getComponentName
());
return
$graph
;
}
/**
* execute
* @param string $query
* @param array $array
* @param integer $limit
* @param integer $offset
*/
public
function
execute
(
$query
,
array
$array
=
array
(),
$limit
=
null
,
$offset
=
null
)
{
$coll
=
new
Doctrine_Collection
(
$this
);
...
...
tests/BatchIteratorTestCase.class.php
View file @
09ca6e46
...
...
@@ -2,7 +2,7 @@
require_once
(
"UnitTestCase.class.php"
);
class
Doctrine_BatchIteratorTestCase
extends
Doctrine_UnitTestCase
{
public
function
testIterator
()
{
$graph
=
new
Doctrine_
DQL_Parser
(
$this
->
session
);
$graph
=
new
Doctrine_
Query
(
$this
->
session
);
$entities
=
$graph
->
query
(
"FROM Entity"
);
$i
=
0
;
foreach
(
$entities
as
$entity
)
{
...
...
tests/run.php
View file @
09ca6e46
...
...
@@ -16,6 +16,7 @@ require_once("CollectionTestCase.class.php");
require_once
(
"CacheSqliteTestCase.class.php"
);
require_once
(
"CollectionOffsetTestCase.class.php"
);
require_once
(
"SenseiTestCase.class.php"
);
require_once
(
"QueryTestCase.class.php"
);
print
"<pre>"
;
...
...
@@ -33,35 +34,27 @@ $test->addTestCase(new Doctrine_TableTestCase());
$test
->
addTestCase
(
new
Doctrine_SessionTestCase
());
$test
->
addTestCase
(
new
Doctrine_DQL_ParserTestCase
());
//
$test->addTestCase(new Doctrine_DQL_ParserTestCase());
$test
->
addTestCase
(
new
Doctrine_ValidatorTestCase
());
$test
->
addTestCase
(
new
Doctrine_ManagerTestCase
());
$test
->
addTestCase
(
new
Doctrine_AccessTestCase
());
$test
->
addTestCase
(
new
Doctrine_EventListenerTestCase
());
$test
->
addTestCase
(
new
Doctrine_BatchIteratorTestCase
());
$test
->
addTestCase
(
new
Doctrine_ConfigurableTestCase
());
$test
->
addTestCase
(
new
Doctrine_CollectionTestCase
());
$test
->
addTestCase
(
new
Doctrine_Collection_OffsetTestCase
());
$test
->
addTestCase
(
new
Sensei_UnitTestCase
());
$test
->
addTestCase
(
new
Doctrine_QueryTestCase
());
//$test->addTestCase(new Doctrine_Cache_FileTestCase());
//$test->addTestCase(new Doctrine_Cache_SqliteTestCase());
...
...
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