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
7a9a86a5
Commit
7a9a86a5
authored
Apr 17, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes #310
parent
b81f399c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
9 deletions
+52
-9
Statement.php
lib/Doctrine/Db/Statement.php
+4
-0
Record.php
lib/Doctrine/Record.php
+23
-8
Table.php
lib/Doctrine/Table.php
+2
-1
StateTestCase.php
tests/Record/StateTestCase.php
+23
-0
No files found.
lib/Doctrine/Db/Statement.php
View file @
7a9a86a5
...
@@ -42,6 +42,10 @@ class Doctrine_Db_Statement implements Doctrine_Adapter_Statement_Interface
...
@@ -42,6 +42,10 @@ class Doctrine_Db_Statement implements Doctrine_Adapter_Statement_Interface
{
{
$this
->
adapter
=
$adapter
;
$this
->
adapter
=
$adapter
;
$this
->
stmt
=
$stmt
;
$this
->
stmt
=
$stmt
;
if
(
$stmt
===
false
)
{
throw
new
Doctrine_Db_Exception
(
'Unknown statement object given.'
);
}
}
}
/**
/**
*
*
...
...
lib/Doctrine/Record.php
View file @
7a9a86a5
...
@@ -382,7 +382,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
...
@@ -382,7 +382,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
*
*
* @return integer
* @return integer
*/
*/
private
function
cleanData
(
$debug
=
false
)
private
function
cleanData
()
{
{
$tmp
=
$this
->
_data
;
$tmp
=
$this
->
_data
;
...
@@ -397,42 +397,57 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
...
@@ -397,42 +397,57 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this
->
_data
[
$name
]
=
self
::
$null
;
$this
->
_data
[
$name
]
=
self
::
$null
;
}
else
{
}
else
{
switch
(
$type
)
{
switch
(
$type
)
{
case
"array"
:
case
'array'
:
case
"object"
:
case
'object'
:
if
(
$tmp
[
$name
]
!==
self
::
$null
)
{
if
(
$tmp
[
$name
]
!==
self
::
$null
)
{
if
(
is_string
(
$tmp
[
$name
]))
{
if
(
is_string
(
$tmp
[
$name
]))
{
$value
=
unserialize
(
$tmp
[
$name
]);
$value
=
unserialize
(
$tmp
[
$name
]);
if
(
$value
===
false
)
if
(
$value
===
false
)
throw
new
Doctrine_Record_Exception
(
"Unserialization of
$name
failed."
);
throw
new
Doctrine_Record_Exception
(
'Unserialization of '
.
$name
.
' failed.'
);
}
else
{
}
else
{
$value
=
$tmp
[
$name
];
$value
=
$tmp
[
$name
];
}
}
$this
->
_data
[
$name
]
=
$value
;
$this
->
_data
[
$name
]
=
$value
;
}
}
break
;
break
;
case
"gzip"
:
case
'gzip'
:
if
(
$tmp
[
$name
]
!==
self
::
$null
)
{
if
(
$tmp
[
$name
]
!==
self
::
$null
)
{
$value
=
gzuncompress
(
$tmp
[
$name
]);
$value
=
gzuncompress
(
$tmp
[
$name
]);
if
(
$value
===
false
)
if
(
$value
===
false
)
throw
new
Doctrine_Record_Exception
(
"Uncompressing of
$name
failed."
);
throw
new
Doctrine_Record_Exception
(
'Uncompressing of '
.
$name
.
' failed.'
);
$this
->
_data
[
$name
]
=
$value
;
$this
->
_data
[
$name
]
=
$value
;
}
}
break
;
break
;
case
"enum"
:
case
'enum'
:
$this
->
_data
[
$name
]
=
$this
->
_table
->
enumValue
(
$name
,
$tmp
[
$name
]);
$this
->
_data
[
$name
]
=
$this
->
_table
->
enumValue
(
$name
,
$tmp
[
$name
]);
break
;
break
;
default
:
default
:
$this
->
_data
[
$name
]
=
$tmp
[
$name
];
$this
->
_data
[
$name
]
=
$tmp
[
$name
];
}
;
}
$count
++
;
$count
++
;
}
}
}
}
return
$count
;
return
$count
;
}
}
/**
* hydrate
* hydrates this object from given array
*
* @param array $data
* @return boolean
*/
public
function
hydrate
(
array
$data
)
{
foreach
(
$data
as
$k
=>
$v
)
{
$this
->
_data
[
$k
]
=
$v
;
}
$this
->
cleanData
();
$this
->
prepareIdentifiers
();
}
/**
/**
* prepareIdentifiers
* prepareIdentifiers
* prepares identifiers for later use
* prepares identifiers for later use
...
...
lib/Doctrine/Table.php
View file @
7a9a86a5
...
@@ -1144,6 +1144,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
...
@@ -1144,6 +1144,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
if
(
isset
(
$this
->
identityMap
[
$id
]))
{
if
(
isset
(
$this
->
identityMap
[
$id
]))
{
$record
=
$this
->
identityMap
[
$id
];
$record
=
$this
->
identityMap
[
$id
];
$record
->
hydrate
(
$this
->
data
);
}
else
{
}
else
{
$recordName
=
$this
->
getClassnameToReturn
();
$recordName
=
$this
->
getClassnameToReturn
();
$record
=
new
$recordName
(
$this
);
$record
=
new
$recordName
(
$this
);
...
@@ -1183,7 +1184,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
...
@@ -1183,7 +1184,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
break
;
break
;
}
}
}
}
if
(
!
$nomatch
)
{
if
(
!
$nomatch
)
{
return
$table
->
getComponentName
();
return
$table
->
getComponentName
();
}
}
}
}
...
...
tests/Record/StateTestCase.php
View file @
7a9a86a5
...
@@ -107,4 +107,27 @@ class Doctrine_Record_State_TestCase extends Doctrine_UnitTestCase {
...
@@ -107,4 +107,27 @@ class Doctrine_Record_State_TestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
$user
->
state
(),
Doctrine_Record
::
STATE_PROXY
);
$this
->
assertEqual
(
$user
->
state
(),
Doctrine_Record
::
STATE_PROXY
);
}
}
public
function
testProxiesAreAutomaticallyUpdatedWithFetches
()
{
$user
=
new
User
();
$user
->
name
=
'someuser'
;
$user
->
password
=
'123'
;
$user
->
save
();
$this
->
connection
->
clear
();
$user
=
$this
->
connection
->
queryOne
(
"SELECT u.name FROM User u WHERE u.name = 'someuser'"
);
$this
->
assertEqual
(
$user
->
state
(),
Doctrine_Record
::
STATE_PROXY
);
$user2
=
$this
->
connection
->
queryOne
(
"FROM User u WHERE u.name = 'someuser'"
);
$this
->
assertEqual
(
$user
->
getOID
(),
$user2
->
getOID
());
$count
=
count
(
$this
->
dbh
);
$this
->
assertEqual
(
$user
->
password
,
'123'
);
$this
->
assertEqual
(
$count
,
count
(
$this
->
dbh
));
}
}
}
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