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
615dcdb8
Commit
615dcdb8
authored
Jul 05, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
ce1002a0
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
35 additions
and
92 deletions
+35
-92
Configurable.php
lib/Doctrine/Configurable.php
+1
-1
Hydrate.php
lib/Doctrine/Hydrate.php
+6
-3
Manager.php
lib/Doctrine/Manager.php
+1
-15
Record.php
lib/Doctrine/Record.php
+8
-8
Filter.php
lib/Doctrine/Record/Filter.php
+1
-44
Table.php
lib/Doctrine/Table.php
+10
-14
EnumTestCase.php
tests/EnumTestCase.php
+6
-5
run.php
tests/run.php
+2
-2
No files found.
lib/Doctrine/Configurable.php
View file @
615dcdb8
...
...
@@ -31,7 +31,7 @@
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
abstract
class
Doctrine_Configurable
abstract
class
Doctrine_Configurable
extends
Doctrine_Object
{
/**
* @var array $attributes an array of containing all attributes
...
...
lib/Doctrine/Hydrate.php
View file @
615dcdb8
...
...
@@ -946,7 +946,7 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable
return
$array
;
}
while
(
$data
=
$stmt
->
fetch
(
PDO
::
FETCH_ASSOC
))
{
while
(
$data
=
$stmt
->
fetch
(
Doctrine
::
FETCH_ASSOC
))
{
$parse
=
true
;
...
...
@@ -965,6 +965,7 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable
$map
=
$this
->
_aliasMap
[
$cache
[
$key
][
'alias'
]];
$table
=
$map
[
'table'
];
$alias
=
$cache
[
$key
][
'alias'
];
$field
=
$cache
[
$key
][
'field'
];
$componentName
=
$map
[
'table'
]
->
getComponentName
();
if
(
isset
(
$map
[
'relation'
]))
{
...
...
@@ -1039,8 +1040,10 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable
$currData
[
$alias
]
=
array
();
$identifiable
[
$alias
]
=
null
;
}
$field
=
$cache
[
$key
][
'field'
];
$currData
[
$alias
][
$field
]
=
$value
;
$currData
[
$alias
][
$field
]
=
$table
->
prepareValue
(
$field
,
$value
);
$index
=
false
;
if
(
$value
!==
null
)
{
$identifiable
[
$alias
]
=
true
;
...
...
lib/Doctrine/Manager.php
View file @
615dcdb8
...
...
@@ -53,10 +53,6 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
* @var string $root root directory
*/
protected
$_root
;
/**
* @var Doctrine_Null $null Doctrine_Null object, used for extremely fast null value checking
*/
protected
$_null
;
/**
* @var array $_integrityActions an array containing all registered integrity actions
* used when emulating these actions
...
...
@@ -72,11 +68,8 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
private
function
__construct
()
{
$this
->
_root
=
dirname
(
__FILE__
);
$this
->
_null
=
new
Doctrine_Null
;
Doctrine_Record_Iterator
::
initNullObject
(
$this
->
_null
);
Doctrine_Validator
::
initNullObject
(
$this
->
_null
);
Doctrine_Object
::
initNullObject
(
$this
->
_null
);
Doctrine_Object
::
initNullObject
(
new
Doctrine_Null
);
}
public
function
addDeleteAction
(
$componentName
,
$foreignComponent
,
$action
)
{
...
...
@@ -102,13 +95,6 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
return
$this
->
_integrityActions
[
$componentName
][
'onUpdate'
];
}
/**
* @return Doctrine_Null
*/
final
public
function
getNullObject
()
{
return
$this
->
_null
;
}
/**
* setDefaultAttributes
* sets default attributes
...
...
lib/Doctrine/Record.php
View file @
615dcdb8
...
...
@@ -162,8 +162,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
// get the column count
$count
=
count
(
$this
->
_data
);
// clean data array
$this
->
_data
=
$this
->
_filter
->
cleanData
(
$this
->
_data
);
$this
->
prepareIdentifiers
(
$exists
);
...
...
@@ -625,12 +624,13 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
}
$id
=
array_values
(
$id
);
$query
=
'SELECT * FROM '
.
$this
->
_table
->
getOption
(
'tableName'
)
.
' WHERE '
.
implode
(
' = ? AND '
,
$this
->
_table
->
getPrimaryKeys
())
.
' = ?'
;
$stmt
=
$this
->
_table
->
getConnection
()
->
execute
(
$query
,
$id
);
$records
=
Doctrine_Query
::
create
()
->
from
(
$this
->
_table
->
getComponentName
())
->
where
(
implode
(
' = ? AND '
,
$this
->
_table
->
getPrimaryKeys
())
.
' = ?'
)
->
execute
(
$id
);
$this
->
_data
=
$stmt
->
fetch
(
PDO
::
FETCH_ASSOC
);
if
(
!
$this
->
_data
)
{
if
(
count
(
$records
)
===
0
)
{
throw
new
Doctrine_Record_Exception
(
'Failed to refresh. Record does not exist.'
);
}
...
...
@@ -645,7 +645,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
$this
->
_table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onLoad
(
$this
);
return
true
;
return
$this
;
}
/**
* factoryRefresh
...
...
@@ -1049,7 +1049,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
default
:
if
(
$this
->
_data
[
$v
]
instanceof
Doctrine_Record
)
{
$this
->
_data
[
$v
]
=
$this
->
_data
[
$v
]
->
getIncremented
();
}
}
$a
[
$v
]
=
$this
->
_data
[
$v
];
}
...
...
lib/Doctrine/Record/Filter.php
View file @
615dcdb8
...
...
@@ -111,52 +111,9 @@ class Doctrine_Record_Filter extends Doctrine_Object
*/
public
function
cleanData
(
$data
)
{
$tmp
=
$data
;
$data
=
array
();
foreach
(
$this
->
_record
->
getTable
()
->
getColumnNames
()
as
$name
)
{
$type
=
$this
->
_record
->
getTable
()
->
getTypeOf
(
$name
);
if
(
!
isset
(
$tmp
[
$name
]))
{
if
(
!
isset
(
$data
[
$name
]))
{
$data
[
$name
]
=
self
::
$_null
;
}
else
{
switch
(
$type
)
{
case
'array'
:
case
'object'
:
if
(
$tmp
[
$name
]
!==
self
::
$_null
)
{
if
(
is_string
(
$tmp
[
$name
]))
{
$value
=
unserialize
(
$tmp
[
$name
]);
if
(
$value
===
false
)
{
throw
new
Doctrine_Record_Exception
(
'Unserialization of '
.
$name
.
' failed.'
);
}
}
else
{
$value
=
$tmp
[
$name
];
}
$data
[
$name
]
=
$value
;
}
break
;
case
'gzip'
:
if
(
$tmp
[
$name
]
!==
self
::
$_null
)
{
$value
=
gzuncompress
(
$tmp
[
$name
]);
if
(
$value
===
false
)
{
throw
new
Doctrine_Record_Exception
(
'Uncompressing of '
.
$name
.
' failed.'
);
}
$data
[
$name
]
=
$value
;
}
break
;
case
'enum'
:
$data
[
$name
]
=
$this
->
_record
->
getTable
()
->
enumValue
(
$name
,
$tmp
[
$name
]);
break
;
case
'boolean'
:
$data
[
$name
]
=
(
boolean
)
$tmp
[
$name
];
break
;
default
:
$data
[
$name
]
=
$tmp
[
$name
];
}
}
}
return
$data
;
...
...
lib/Doctrine/Table.php
View file @
615dcdb8
...
...
@@ -811,20 +811,16 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
$id
=
array_values
(
$id
);
}
$query
=
'SELECT '
.
implode
(
', '
,
array_keys
(
$this
->
columns
))
.
' FROM '
.
$this
->
getTableName
()
.
' WHERE '
.
implode
(
' = ? AND '
,
$this
->
primaryKeys
)
.
' = ?'
;
$query
=
$this
->
applyInheritance
(
$query
);
$records
=
Doctrine_Query
::
create
()
->
from
(
$this
->
getComponentName
())
->
where
(
implode
(
' = ? AND '
,
$this
->
primaryKeys
)
.
' = ?'
)
->
execute
(
$id
);
$params
=
array_merge
(
$id
,
array_values
(
$this
->
options
[
'inheritanceMap'
]));
$stmt
=
$this
->
conn
->
execute
(
$query
,
$params
);
$this
->
data
=
$stmt
->
fetch
(
PDO
::
FETCH_ASSOC
);
if
(
$this
->
data
===
false
)
if
(
count
(
$records
)
===
0
)
{
return
false
;
}
return
$
this
->
getRecord
();
return
$
records
->
getFirst
();
}
return
false
;
}
...
...
@@ -967,7 +963,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
$inheritanceMap
=
$table
->
getOption
(
'inheritanceMap'
);
$nomatch
=
false
;
foreach
(
$inheritanceMap
as
$key
=>
$value
)
{
if
(
!
isset
(
$this
->
data
[
$key
])
||
$this
->
data
[
$key
]
!
=
$value
)
{
if
(
!
isset
(
$this
->
data
[
$key
])
||
$this
->
data
[
$key
]
!=
=
$value
)
{
$nomatch
=
true
;
break
;
}
...
...
@@ -1178,7 +1174,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
*/
public
function
prepareValue
(
$field
,
$value
)
{
if
(
$value
===
null
)
{
if
(
$value
===
null
||
$value
===
self
::
$_null
)
{
return
self
::
$_null
;
}
else
{
$type
=
$this
->
getTypeOf
(
$field
);
...
...
@@ -1211,7 +1207,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
break
;
case
'integer'
:
return
(
int
)
$value
;
break
;
break
;
}
}
return
$value
;
...
...
tests/EnumTestCase.php
View file @
615dcdb8
...
...
@@ -39,7 +39,7 @@ class Doctrine_Enum_TestCase extends Doctrine_UnitTestCase
$this
->
tables
=
array
(
"EnumTest"
,
"EnumTest2"
,
"EnumTest3"
);
parent
::
prepareTables
();
}
/**
public
function
testParameterConversion
()
{
$test
=
new
EnumTest
();
...
...
@@ -97,6 +97,7 @@ class Doctrine_Enum_TestCase extends Doctrine_UnitTestCase
$this
->
fail
();
}
}
public
function
testNotEqual
()
{
try
{
...
...
@@ -107,7 +108,7 @@ class Doctrine_Enum_TestCase extends Doctrine_UnitTestCase
$this
->
fail
();
}
}
*/
public
function
testEnumType
()
{
...
...
@@ -164,13 +165,13 @@ class Doctrine_Enum_TestCase extends Doctrine_UnitTestCase
$this
->
conn
->
exec
(
'DELETE FROM enum_test WHERE id = 1'
);
$f
=
false
;
try
{
$enum
->
refresh
();
$this
->
fail
();
}
catch
(
Doctrine_Record_Exception
$e
)
{
$
f
=
true
;
$
this
->
pass
()
;
}
$this
->
assertTrue
(
$f
);
}
public
function
testEnumFetchArray
()
{
...
...
tests/run.php
View file @
615dcdb8
...
...
@@ -70,7 +70,7 @@ $test = new GroupTest('Doctrine Framework Unit Tests');
$test->addTestCase(new Doctrine_Ticket330_TestCase());
*/
/** */
/**
*/
// Connection drivers (not yet fully tested)
$test
->
addTestCase
(
new
Doctrine_Connection_Pgsql_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Connection_Oracle_TestCase
());
...
...
@@ -182,7 +182,6 @@ $test->addTestCase(new Doctrine_Relation_Parser_TestCase());
// Datatypes
$test
->
addTestCase
(
new
Doctrine_Enum_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Boolean_TestCase
());
// Utility components
...
...
@@ -190,6 +189,7 @@ $test->addTestCase(new Doctrine_Boolean_TestCase());
//$test->addTestCase(new Doctrine_PessimisticLocking_TestCase());
$test
->
addTestCase
(
new
Doctrine_View_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Validator_TestCase
());
...
...
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