Skip to content
Snippets Groups Projects
Commit de5ca086 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Database.php: changed getTableDefinition() from PDO to sql

parent 3ac5ffb6
No related branches found
No related tags found
No related merge requests found
......@@ -162,15 +162,7 @@ class Database {
* @return array column definition of table as returned by SHOW FIELDS FROM as associative array.
*/
public function getTableDefinition($table) {
$statement = $this->pdo->query("SHOW FIELDS FROM `$table`");
return $statement->fetchAll(\PDO::FETCH_ASSOC);
}
/**
* @return mixed
*/
public function getLastInsertId() {
return $this->pdo->lastInsertId();
return $this->sql("SHOW FIELDS FROM `$table`");
}
/**
......@@ -293,4 +285,11 @@ class Database {
return $this->stmt->fetch(\PDO::FETCH_ASSOC);
}
/**
* @return mixed
*/
public function getLastInsertId() {
return $this->pdo->lastInsertId();
}
}
\ No newline at end of file
DROP TABLE IF EXISTS Person;
CREATE TABLE person (
CREATE TABLE Person (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
name 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 ''
);
......@@ -14,8 +14,8 @@ INSERT INTO Person (id, name, firstname, gender, groups) VALUES
(NULL, 'Smith', 'Jane', 'female', 'a,c');
DROP TABLE IF EXISTS address;
CREATE TABLE address (
DROP TABLE IF EXISTS Address;
CREATE TABLE Address (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
person_id BIGINT,
street VARCHAR(128),
......@@ -24,8 +24,8 @@ CREATE TABLE address (
gr_id_typ BIGINT
);
DROP TABLE IF EXISTS gruppe;
CREATE TABLE gruppe (
DROP TABLE IF EXISTS Gruppe;
CREATE TABLE Gruppe (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255),
value VARCHAR(255),
......
......@@ -171,12 +171,12 @@ class DatabaseTest extends AbstractDatabaseTest {
*
*/
public function testGetSetValueList() {
$valueList = $this->db->getEnumSetValueList('person', 'gender');
$valueList = $this->db->getEnumSetValueList('Person', 'gender');
$expected = [0 => '', 1 => 'male', 2 => 'female'];
$this->assertEquals($expected, $valueList);
$expected = [0 => '', 1 => 'a', 2 => 'b', 3 => 'c'];
$valueList = $this->db->getEnumSetValueList('person', 'groups');
$valueList = $this->db->getEnumSetValueList('Person', 'groups');
$this->assertEquals($expected, $valueList);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment