Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
typo3
qfq
Commits
de5ca086
Commit
de5ca086
authored
Jan 17, 2016
by
Carsten Rose
Browse files
Database.php: changed getTableDefinition() from PDO to sql
parent
3ac5ffb6
Changes
3
Hide whitespace changes
Inline
Side-by-side
qfq/Database.php
View file @
de5ca086
...
@@ -162,15 +162,7 @@ class Database {
...
@@ -162,15 +162,7 @@ class Database {
* @return array column definition of table as returned by SHOW FIELDS FROM as associative array.
* @return array column definition of table as returned by SHOW FIELDS FROM as associative array.
*/
*/
public
function
getTableDefinition
(
$table
)
{
public
function
getTableDefinition
(
$table
)
{
$statement
=
$this
->
pdo
->
query
(
"SHOW FIELDS FROM `
$table
`"
);
return
$this
->
sql
(
"SHOW FIELDS FROM `
$table
`"
);
return
$statement
->
fetchAll
(
\
PDO
::
FETCH_ASSOC
);
}
/**
* @return mixed
*/
public
function
getLastInsertId
()
{
return
$this
->
pdo
->
lastInsertId
();
}
}
/**
/**
...
@@ -293,4 +285,11 @@ class Database {
...
@@ -293,4 +285,11 @@ class Database {
return
$this
->
stmt
->
fetch
(
\
PDO
::
FETCH_ASSOC
);
return
$this
->
stmt
->
fetch
(
\
PDO
::
FETCH_ASSOC
);
}
}
/**
* @return mixed
*/
public
function
getLastInsertId
()
{
return
$this
->
pdo
->
lastInsertId
();
}
}
}
\ No newline at end of file
sql/testtables.sql
View file @
de5ca086
DROP
TABLE
IF
EXISTS
Person
;
DROP
TABLE
IF
EXISTS
Person
;
CREATE
TABLE
p
erson
(
CREATE
TABLE
P
erson
(
id
BIGINT
AUTO_INCREMENT
PRIMARY
KEY
,
id
BIGINT
AUTO_INCREMENT
PRIMARY
KEY
,
name
VARCHAR
(
128
),
name
VARCHAR
(
128
),
firstname
VARCHAR
(
128
),
firstname
VARCHAR
(
128
),
gender
ENUM
(
''
,
'male'
,
'female'
)
NOT
NULL
DEFAULT
''
,
gender
ENUM
(
''
,
'male'
,
'female'
)
NOT
NULL
DEFAULT
'
male
'
,
groups
SET
(
''
,
'a'
,
'b'
,
'c'
)
NOT
NULL
DEFAULT
''
groups
SET
(
''
,
'a'
,
'b'
,
'c'
)
NOT
NULL
DEFAULT
''
);
);
...
@@ -14,8 +14,8 @@ INSERT INTO Person (id, name, firstname, gender, groups) VALUES
...
@@ -14,8 +14,8 @@ INSERT INTO Person (id, name, firstname, gender, groups) VALUES
(
NULL
,
'Smith'
,
'Jane'
,
'female'
,
'a,c'
);
(
NULL
,
'Smith'
,
'Jane'
,
'female'
,
'a,c'
);
DROP
TABLE
IF
EXISTS
a
ddress
;
DROP
TABLE
IF
EXISTS
A
ddress
;
CREATE
TABLE
a
ddress
(
CREATE
TABLE
A
ddress
(
id
BIGINT
AUTO_INCREMENT
PRIMARY
KEY
,
id
BIGINT
AUTO_INCREMENT
PRIMARY
KEY
,
person_id
BIGINT
,
person_id
BIGINT
,
street
VARCHAR
(
128
),
street
VARCHAR
(
128
),
...
@@ -24,8 +24,8 @@ CREATE TABLE address (
...
@@ -24,8 +24,8 @@ CREATE TABLE address (
gr_id_typ
BIGINT
gr_id_typ
BIGINT
);
);
DROP
TABLE
IF
EXISTS
g
ruppe
;
DROP
TABLE
IF
EXISTS
G
ruppe
;
CREATE
TABLE
g
ruppe
(
CREATE
TABLE
G
ruppe
(
id
BIGINT
AUTO_INCREMENT
PRIMARY
KEY
,
id
BIGINT
AUTO_INCREMENT
PRIMARY
KEY
,
name
VARCHAR
(
255
),
name
VARCHAR
(
255
),
value
VARCHAR
(
255
),
value
VARCHAR
(
255
),
...
...
tests/phpunit/DatabaseTest.php
View file @
de5ca086
...
@@ -171,12 +171,12 @@ class DatabaseTest extends AbstractDatabaseTest {
...
@@ -171,12 +171,12 @@ class DatabaseTest extends AbstractDatabaseTest {
*
*
*/
*/
public
function
testGetSetValueList
()
{
public
function
testGetSetValueList
()
{
$valueList
=
$this
->
db
->
getEnumSetValueList
(
'
p
erson'
,
'gender'
);
$valueList
=
$this
->
db
->
getEnumSetValueList
(
'
P
erson'
,
'gender'
);
$expected
=
[
0
=>
''
,
1
=>
'male'
,
2
=>
'female'
];
$expected
=
[
0
=>
''
,
1
=>
'male'
,
2
=>
'female'
];
$this
->
assertEquals
(
$expected
,
$valueList
);
$this
->
assertEquals
(
$expected
,
$valueList
);
$expected
=
[
0
=>
''
,
1
=>
'a'
,
2
=>
'b'
,
3
=>
'c'
];
$expected
=
[
0
=>
''
,
1
=>
'a'
,
2
=>
'b'
,
3
=>
'c'
];
$valueList
=
$this
->
db
->
getEnumSetValueList
(
'
p
erson'
,
'groups'
);
$valueList
=
$this
->
db
->
getEnumSetValueList
(
'
P
erson'
,
'groups'
);
$this
->
assertEquals
(
$expected
,
$valueList
);
$this
->
assertEquals
(
$expected
,
$valueList
);
}
}
...
...
Write
Preview
Supports
Markdown
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