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
b4dad07a
Commit
b4dad07a
authored
Dec 30, 2010
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DBAL-79 - Add Schema\Table::hasPrimaryKey() method.
parent
37186d98
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
+25
-0
Table.php
lib/Doctrine/DBAL/Schema/Table.php
+10
-0
TableTest.php
tests/Doctrine/Tests/DBAL/Schema/TableTest.php
+15
-0
No files found.
lib/Doctrine/DBAL/Schema/Table.php
View file @
b4dad07a
...
...
@@ -524,6 +524,16 @@ class Table extends AbstractAsset
return
$this
->
getIndex
(
$this
->
_primaryKeyName
);
}
/**
* Check if this table has a primary key.
*
* @return bool
*/
public
function
hasPrimaryKey
()
{
return
(
$this
->
_primaryKeyName
&&
$this
->
hasIndex
(
$this
->
_primaryKeyName
));
}
/**
* @param string $indexName
* @return bool
...
...
tests/Doctrine/Tests/DBAL/Schema/TableTest.php
View file @
b4dad07a
...
...
@@ -416,4 +416,19 @@ class TableTest extends \PHPUnit_Framework_TestCase
$this
->
assertEquals
(
'`bar`'
,
$table
->
getQuotedName
(
$mysqlPlatform
));
$this
->
assertEquals
(
'"bar"'
,
$table
->
getQuotedName
(
$sqlitePlatform
));
}
/**
* @group DBAL-79
*/
public
function
testTableHasPrimaryKey
()
{
$table
=
new
Table
(
"test"
);
$this
->
assertFalse
(
$table
->
hasPrimaryKey
());
$table
->
addColumn
(
"foo"
,
"integer"
);
$table
->
setPrimaryKey
(
array
(
"foo"
));
$this
->
assertTrue
(
$table
->
hasPrimaryKey
());
}
}
\ No newline at end of file
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