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
f2895955
Commit
f2895955
authored
Jun 07, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
7a00232c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
4 deletions
+27
-4
AuditLog.php
lib/Doctrine/AuditLog.php
+27
-4
No files found.
lib/Doctrine/AuditLog.php
View file @
f2895955
...
@@ -40,10 +40,13 @@ class Doctrine_AuditLog
...
@@ -40,10 +40,13 @@ class Doctrine_AuditLog
);
);
protected
$_table
;
protected
$_table
;
protected
$_auditTable
;
public
function
__construct
(
Doctrine_Table
$table
)
public
function
__construct
(
Doctrine_Table
$table
)
{
{
$this
->
_table
=
$table
;
$this
->
_table
=
$table
;
}
}
/**
/**
* __get
* __get
...
@@ -127,7 +130,25 @@ class Doctrine_AuditLog
...
@@ -127,7 +130,25 @@ class Doctrine_AuditLog
$conn
->
rollback
();
$conn
->
rollback
();
}
}
}
}
public
function
getVersion
(
Doctrine_Record
$record
,
$version
)
{
$className
=
str_replace
(
'%CLASS%'
,
$this
->
_table
->
getComponentName
(),
$this
->
_options
[
'className'
]);
$q
=
new
Doctrine_Query
();
$values
=
array
();
foreach
((
array
)
$this
->
_table
->
getIdentifier
()
as
$id
)
{
$conditions
[]
=
$className
.
'.'
.
$id
.
' = ?'
;
$values
[]
=
$record
->
get
(
$id
);
}
$where
=
implode
(
' AND '
,
$conditions
)
.
' AND '
.
$className
.
'.'
.
$this
->
_options
[
'versionColumn'
]
.
' = ?'
;
$values
[]
=
$version
;
return
$q
->
from
(
$className
)
->
where
(
$where
)
->
execute
(
$values
,
Doctrine
::
FETCH_ARRAY
);
}
public
function
createVersionTable
()
public
function
createVersionTable
()
{
{
$data
=
$this
->
_table
->
getExportableFormat
(
false
);
$data
=
$this
->
_table
->
getExportableFormat
(
false
);
...
@@ -140,7 +161,7 @@ class Doctrine_AuditLog
...
@@ -140,7 +161,7 @@ class Doctrine_AuditLog
unset
(
$data
[
'columns'
][
$name
][
'sequence'
]);
unset
(
$data
[
'columns'
][
$name
][
'sequence'
]);
unset
(
$data
[
'columns'
][
$name
][
'seq'
]);
unset
(
$data
[
'columns'
][
$name
][
'seq'
]);
}
}
$data
[
'columns'
][
$this
->
_options
[
'versionColumn'
]][
'primary'
]
=
true
;
$className
=
str_replace
(
'%CLASS%'
,
$this
->
_table
->
getComponentName
(),
$this
->
_options
[
'className'
]);
$className
=
str_replace
(
'%CLASS%'
,
$this
->
_table
->
getComponentName
(),
$this
->
_options
[
'className'
]);
$definition
=
'class '
.
$className
$definition
=
'class '
.
$className
...
@@ -157,10 +178,12 @@ class Doctrine_AuditLog
...
@@ -157,10 +178,12 @@ class Doctrine_AuditLog
$this
->
_table
->
addListener
(
new
Doctrine_AuditLog_Listener
(
$this
));
$this
->
_table
->
addListener
(
new
Doctrine_AuditLog_Listener
(
$this
));
eval
(
$definition
);
eval
(
$definition
);
$data
[
'options'
][
'primary'
][]
=
$this
->
_options
[
'versionColumn'
];
$conn
->
export
->
createTable
(
$data
[
'tableName'
],
$data
[
'columns'
],
$data
[
'options'
]
);
$this
->
_auditTable
=
$this
->
_table
->
getConnection
()
->
getTable
(
$className
);
}
}
/**
/**
* deleteTriggerSql
* deleteTriggerSql
...
@@ -173,7 +196,7 @@ class Doctrine_AuditLog
...
@@ -173,7 +196,7 @@ class Doctrine_AuditLog
$columnNames
=
$this
->
_table
->
getColumnNames
();
$columnNames
=
$this
->
_table
->
getColumnNames
();
$oldColumns
=
array_map
(
array
(
$this
,
'formatOld'
),
$columnNames
);
$oldColumns
=
array_map
(
array
(
$this
,
'formatOld'
),
$columnNames
);
$sql
=
'CREATE TRIGGER '
$sql
=
'CREATE TRIGGER '
.
$conn
->
quoteIdentifier
(
$this
->
_table
->
getTableName
())
.
'_ddt'
.
' DELETE ON '
.
$conn
->
quoteIdentifier
(
$this
->
_table
->
getTableName
())
.
'_ddt'
.
'
BEFORE
DELETE ON '
.
$conn
->
quoteIdentifier
(
$this
->
_table
->
getTableName
())
.
$conn
->
quoteIdentifier
(
$this
->
_table
->
getTableName
())
.
' BEGIN'
.
' BEGIN'
.
' INSERT INTO '
.
$this
->
_table
->
getTableName
()
.
'_dvt ('
.
' INSERT INTO '
.
$this
->
_table
->
getTableName
()
.
'_dvt ('
...
...
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