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
33bb25ac
Commit
33bb25ac
authored
May 16, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
936d442c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
120 deletions
+34
-120
Connection.php
lib/Doctrine/Connection.php
+1
-1
UnitOfWork.php
lib/Doctrine/Connection/UnitOfWork.php
+2
-1
Hydrate.php
lib/Doctrine/Hydrate.php
+1
-1
Record.php
lib/Doctrine/Record.php
+17
-101
Filter.php
lib/Doctrine/Record/Filter.php
+13
-16
No files found.
lib/Doctrine/Connection.php
View file @
33bb25ac
...
...
@@ -492,7 +492,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
// prepare and execute the statement
$this
->
execute
(
$query
,
array_values
(
$values
));
print
$query
.
'('
.
implode
(
', '
,
$values
)
.
")<br>"
;
return
true
;
}
/**
...
...
lib/Doctrine/Connection/UnitOfWork.php
View file @
33bb25ac
...
...
@@ -77,8 +77,9 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
$type
=
$rel
->
getType
();
// skip self-referenced relations
if
(
$name
===
$nm
)
if
(
$name
===
$nm
)
{
continue
;
}
if
(
$rel
instanceof
Doctrine_Relation_ForeignKey
)
{
if
(
$index2
!==
false
)
{
...
...
lib/Doctrine/Hydrate.php
View file @
33bb25ac
...
...
@@ -403,7 +403,7 @@ class Doctrine_Hydrate
// we keep track of all the collections
$colls
=
array
();
$colls
[]
=
$coll
;
print_r
(
$array
);
$colls
[]
=
$coll
;
$prevRow
=
array
();
/**
* iterate over the fetched data
...
...
lib/Doctrine/Record.php
View file @
33bb25ac
...
...
@@ -107,6 +107,10 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @var Doctrine_Validator_ErrorStack error stack object
*/
protected
$_errorStack
;
/**
* @var Doctrine_Record_Filter the filter object
*/
protected
$_filter
;
/**
* @var array $references an array containing all the references
*/
...
...
@@ -149,6 +153,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$exists
=
false
;
}
// initialize the filter object
$this
->
_filter
=
new
Doctrine_Record_Filter
(
$this
);
// Check if the current connection has the records table in its registry
// If not this record is only used for creating table definition and setting up
...
...
@@ -176,7 +183,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$count
=
count
(
$this
->
_data
);
// clean data array
$this
->
cleanData
(
);
$this
->
_data
=
$this
->
_filter
->
cleanData
(
$this
->
_data
);
$this
->
prepareIdentifiers
(
$exists
);
...
...
@@ -354,86 +361,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
}
}
}
/**
* cleanData
* this method does several things to records internal data
*
* 1. It unserializes array and object typed columns
* 2. Uncompresses gzip typed columns
* 3. Gets the appropriate enum values for enum typed columns
* 4. Initializes special null object pointer for null values (for fast column existence checking purposes)
*
*
* example:
*
* $data = array("name"=>"John","lastname"=> null, "id" => 1,"unknown" => "unknown");
* $names = array("name", "lastname", "id");
* $data after operation:
* $data = array("name"=>"John","lastname" => Object(Doctrine_Null));
*
* here column 'id' is removed since its auto-incremented primary key (read-only)
*
* @throws Doctrine_Record_Exception if unserialization of array/object typed column fails or
* if uncompression of gzip typed column fails
*
* @return integer
*/
private
function
cleanData
()
{
$tmp
=
$this
->
_data
;
$this
->
_data
=
array
();
$count
=
0
;
foreach
(
$this
->
_table
->
getColumnNames
()
as
$name
)
{
$type
=
$this
->
_table
->
getTypeOf
(
$name
);
if
(
!
isset
(
$tmp
[
$name
]))
{
$this
->
_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
];
}
$this
->
_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.'
);
$this
->
_data
[
$name
]
=
$value
;
}
break
;
case
'enum'
:
$this
->
_data
[
$name
]
=
$this
->
_table
->
enumValue
(
$name
,
$tmp
[
$name
]);
break
;
case
'boolean'
:
case
'integer'
:
if
(
$tmp
[
$name
]
!==
self
::
$null
&&
!
(
$tmp
[
$name
]
instanceof
Doctrine_Record
))
{
settype
(
$tmp
[
$name
],
$type
);
}
default
:
$this
->
_data
[
$name
]
=
$tmp
[
$name
];
}
$count
++
;
}
}
return
$count
;
}
/**
* hydrate
* hydrates this object from given array
...
...
@@ -446,7 +373,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
foreach
(
$data
as
$k
=>
$v
)
{
$this
->
_data
[
$k
]
=
$v
;
}
$this
->
cleanData
(
);
$this
->
_data
=
$this
->
_filter
->
cleanData
(
$this
->
_data
);
$this
->
prepareIdentifiers
();
}
/**
...
...
@@ -562,7 +489,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this
->
_table
->
getRepository
()
->
add
(
$this
);
$this
->
cleanData
(
);
$this
->
_data
=
$this
->
_filter
->
cleanData
(
$this
->
_data
);
$this
->
prepareIdentifiers
(
$this
->
exists
());
...
...
@@ -640,10 +567,10 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
}
$id
=
array_values
(
$id
);
$query
=
$this
->
_table
->
getQuery
()
.
" WHERE "
.
implode
(
" = ? AND "
,
$this
->
_table
->
getPrimaryKeys
())
.
" = ?"
;
$stmt
=
$this
->
_table
->
getConnection
()
->
execute
(
$query
,
$id
);
$query
=
$this
->
_table
->
getQuery
()
.
' WHERE '
.
implode
(
' = ? AND '
,
$this
->
_table
->
getPrimaryKeys
())
.
' = ?'
;
$stmt
=
$this
->
_table
->
getConnection
()
->
execute
(
$query
,
$id
);
$this
->
_data
=
$stmt
->
fetch
(
PDO
::
FETCH_ASSOC
);
$this
->
_data
=
$stmt
->
fetch
(
PDO
::
FETCH_ASSOC
);
if
(
!
$this
->
_data
)
throw
new
Doctrine_Record_Exception
(
'Failed to refresh. Record does not exist anymore'
);
...
...
@@ -673,7 +600,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this
->
_data
=
$this
->
_table
->
getData
();
$old
=
$this
->
_id
;
$this
->
cleanData
(
);
$this
->
_data
=
$this
->
_filter
->
cleanData
(
$this
->
_data
);
$this
->
prepareIdentifiers
();
...
...
@@ -1234,7 +1161,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
{
if
(
$id
===
false
)
{
$this
->
_id
=
array
();
$this
->
cleanData
(
);
$this
->
_data
=
$this
->
_filter
->
cleanData
(
$this
->
_data
);
$this
->
_state
=
Doctrine_Record
::
STATE_TCLEAN
;
$this
->
_modified
=
array
();
}
elseif
(
$id
===
true
)
{
...
...
@@ -1266,8 +1193,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
final
public
function
getIncremented
()
{
$id
=
current
(
$this
->
_id
);
if
(
$id
===
false
)
if
(
$id
===
false
)
{
return
null
;
}
return
$id
;
}
...
...
@@ -1305,18 +1233,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
}
throw
new
Doctrine_Record_Exception
(
"Unknown reference
$name
"
);
}
/**
* addReference
* @param Doctrine_Record $record
* @param mixed $key
* @return void
*/
public
function
addReference
(
Doctrine_Record
$record
,
Doctrine_Relation
$connector
,
$key
=
null
)
{
$alias
=
$connector
->
getAlias
();
$this
->
references
[
$alias
]
->
add
(
$record
,
$key
);
}
/**
* getReferences
* @return array all references
...
...
lib/Doctrine/Record/Filter.php
View file @
33bb25ac
...
...
@@ -67,31 +67,28 @@ class Doctrine_Record_Filter
*
* example:
*
* $data = array("name"=>"John","lastname"=> null, "id" => 1,"unknown" => "unknown");
* $names = array("name", "lastname", "id");
* $data = array("name" => "John", "lastname" => null, "id" => 1, "unknown" => "unknown");
* $data after operation:
* $data = array("name"
=>"John",
"lastname" => Object(Doctrine_Null));
* $data = array("name"
=> "John",
"lastname" => Object(Doctrine_Null));
*
* here column 'id' is removed since its auto-incremented primary key (read-only)
*
* @throws Doctrine_Record_Exception if unserialization of array/object typed column fails or
* if uncompression of gzip typed column fails
*
* @param array $data data array to be cleaned
* @return integer
*/
public
function
cleanData
(
)
public
function
cleanData
(
$data
)
{
$tmp
=
$this
->
_data
;
$this
->
_data
=
array
();
$count
=
0
;
$tmp
=
$data
;
$data
=
array
();
foreach
(
$this
->
_table
->
getColumnNames
()
as
$name
)
{
$type
=
$this
->
_table
->
getTypeOf
(
$name
);
if
(
!
isset
(
$tmp
[
$name
]))
{
$
this
->
_
data
[
$name
]
=
self
::
$null
;
$data
[
$name
]
=
self
::
$null
;
}
else
{
switch
(
$type
)
{
case
'array'
:
...
...
@@ -106,7 +103,7 @@ class Doctrine_Record_Filter
}
else
{
$value
=
$tmp
[
$name
];
}
$
this
->
_
data
[
$name
]
=
$value
;
$data
[
$name
]
=
$value
;
}
break
;
case
'gzip'
:
...
...
@@ -117,20 +114,20 @@ class Doctrine_Record_Filter
throw
new
Doctrine_Record_Exception
(
'Uncompressing of '
.
$name
.
' failed.'
);
}
$
this
->
_
data
[
$name
]
=
$value
;
$data
[
$name
]
=
$value
;
}
break
;
case
'enum'
:
$
this
->
_
data
[
$name
]
=
$this
->
_table
->
enumValue
(
$name
,
$tmp
[
$name
]);
$data
[
$name
]
=
$this
->
_table
->
enumValue
(
$name
,
$tmp
[
$name
]);
break
;
default
:
$
this
->
_
data
[
$name
]
=
$tmp
[
$name
];
$data
[
$name
]
=
$tmp
[
$name
];
}
$count
++
;
}
}
return
$
count
;
return
$
data
;
}
/**
* prepareIdentifiers
...
...
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