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
7b53b5e8
Commit
7b53b5e8
authored
7 years ago
by
Eugene Pisarchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reverted public api changes and removed not necessary public methods
parent
e5c2695d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
39 deletions
+34
-39
MySqlPlatform.php
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
+1
-1
Table.php
lib/Doctrine/DBAL/Schema/Table.php
+33
-38
No files found.
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
View file @
7b53b5e8
...
@@ -742,7 +742,7 @@ class MySqlPlatform extends AbstractPlatform
...
@@ -742,7 +742,7 @@ class MySqlPlatform extends AbstractPlatform
foreach
(
$diff
->
changedIndexes
as
$changedIndex
)
{
foreach
(
$diff
->
changedIndexes
as
$changedIndex
)
{
// Changed primary key
// Changed primary key
if
(
$changedIndex
->
isPrimary
()
&&
$diff
->
fromTable
instanceof
Table
)
{
if
(
$changedIndex
->
isPrimary
()
&&
$diff
->
fromTable
instanceof
Table
)
{
foreach
(
$diff
->
fromTable
->
getPrimaryKeyColumn
Name
s
()
as
$columnName
)
{
foreach
(
$diff
->
fromTable
->
getPrimaryKeyColumns
()
as
$columnName
)
{
$column
=
$diff
->
fromTable
->
getColumn
(
$columnName
);
$column
=
$diff
->
fromTable
->
getColumn
(
$columnName
);
// Check if an autoincrement column was dropped from the primary key.
// Check if an autoincrement column was dropped from the primary key.
...
...
This diff is collapsed.
Click to expand it.
lib/Doctrine/DBAL/Schema/Table.php
View file @
7b53b5e8
...
@@ -621,58 +621,38 @@ class Table extends AbstractAsset
...
@@ -621,58 +621,38 @@ class Table extends AbstractAsset
*/
*/
public
function
getColumns
()
public
function
getColumns
()
{
{
return
array_merge
(
$this
->
getPrimaryKeyColumns
(),
$this
->
getForeignKeyColumns
(),
$this
->
_columns
);
$primaryKeyColumns
=
[];
if
(
$this
->
hasPrimaryKey
())
{
$primaryKeyColumns
=
$this
->
filterColumns
(
$this
->
getPrimaryKey
()
->
getColumns
());
}
}
/**
return
array_merge
(
$primaryKeyColumns
,
$this
->
getForeignKeyColumns
(),
$this
->
_columns
);
* Returns primary key columns
* @return Column[]
*/
public
function
getPrimaryKeyColumns
()
{
$primaryKeyColumnNames
=
$this
->
getPrimaryKeyColumnNames
();
return
array_filter
(
$this
->
_columns
,
function
(
$key
)
use
(
$primaryKeyColumnNames
)
{
return
in_array
(
$key
,
$primaryKeyColumnNames
);
},
ARRAY_FILTER_USE_KEY
);
}
}
/**
/**
* Returns foreign key columns
* Returns foreign key columns
* @return Column[]
* @return Column[]
*/
*/
public
function
getForeignKeyColumns
()
private
function
getForeignKeyColumns
()
{
$foreignKeyColumnNames
=
$this
->
getForeignKeyColumnNames
();
return
array_filter
(
$this
->
_columns
,
function
(
$key
)
use
(
$foreignKeyColumnNames
)
{
return
in_array
(
$key
,
$foreignKeyColumnNames
);
},
ARRAY_FILTER_USE_KEY
);
}
/**
* Returns primary key column names
* @return array
*/
public
function
getPrimaryKeyColumnNames
()
{
{
$primaryKeyColumnNames
=
[];
$foreignKeyColumns
=
[];
if
(
$this
->
hasPrimaryKey
())
{
foreach
(
$this
->
getForeignKeys
()
as
$foreignKey
)
{
$primaryKeyColumnNames
=
$this
->
getPrimaryKey
()
->
getColumns
();
/* @var $foreignKey ForeignKeyConstraint */
$foreignKeyColumns
=
array_merge
(
$foreignKeyColumns
,
$foreignKey
->
getColumns
());
}
}
return
$
primaryKeyColumnNames
;
return
$
this
->
filterColumns
(
$foreignKeyColumns
)
;
}
}
/**
/**
* Returns foreign key column names
* Returns only columns that have specified names
* @return array
* @param array $columnNames
* @return Column[]
*/
*/
p
ublic
function
getForeignKeyColumnNames
(
)
p
rivate
function
filterColumns
(
array
$columnNames
)
{
{
$foreignKeyColumnNames
=
[];
return
array_filter
(
$this
->
_columns
,
function
(
$columnName
)
use
(
$columnNames
)
{
foreach
(
$this
->
getForeignKeys
()
as
$foreignKey
)
{
return
in_array
(
$columnName
,
$columnNames
,
true
);
/* @var $foreignKey ForeignKeyConstraint */
},
ARRAY_FILTER_USE_KEY
);
$foreignKeyColumnNames
=
array_merge
(
$foreignKeyColumnNames
,
$foreignKey
->
getColumns
());
}
return
$foreignKeyColumnNames
;
}
}
/**
/**
...
@@ -722,6 +702,21 @@ class Table extends AbstractAsset
...
@@ -722,6 +702,21 @@ class Table extends AbstractAsset
return
$this
->
getIndex
(
$this
->
_primaryKeyName
);
return
$this
->
getIndex
(
$this
->
_primaryKeyName
);
}
}
/**
* Returns the primary key columns.
*
* @return array
*
* @throws DBALException
*/
public
function
getPrimaryKeyColumns
()
{
if
(
!
$this
->
hasPrimaryKey
())
{
throw
new
DBALException
(
"Table "
.
$this
->
getName
()
.
" has no primary key."
);
}
return
$this
->
getPrimaryKey
()
->
getColumns
();
}
/**
/**
* Returns whether this table has a primary key.
* Returns whether this table has a primary key.
*
*
...
...
This diff is collapsed.
Click to expand it.
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