diff options
author | AlexKlimenkov <shurick.klimenkov@gmail.com> | 2015-02-03 14:29:45 +0300 |
---|---|---|
committer | AlexKlimenkov <shurick.klimenkov@gmail.com> | 2015-02-05 13:25:55 +0300 |
commit | f56a0475d90af025e92ec4716ff4e5121992b4fe (patch) | |
tree | c351eff2ed0b007eafed412a513bbec5fb4c5f91 /codebase/connector/db_pdo.php | |
parent | 32504c39dd0183ac30da815e4cf41ac8fa022b99 (diff) | |
download | scheduler-f56a0475d90af025e92ec4716ff4e5121992b4fe.zip scheduler-f56a0475d90af025e92ec4716ff4e5121992b4fe.tar.gz scheduler-f56a0475d90af025e92ec4716ff4e5121992b4fe.tar.bz2 |
[update] version 4.3.0v4.3.0
Diffstat (limited to 'codebase/connector/db_pdo.php')
-rw-r--r-- | codebase/connector/db_pdo.php | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/codebase/connector/db_pdo.php b/codebase/connector/db_pdo.php index d1ad4d8..1417462 100644 --- a/codebase/connector/db_pdo.php +++ b/codebase/connector/db_pdo.php @@ -39,6 +39,31 @@ class PDODBDataWrapper extends DBDataWrapper{ return $sql; } + public function tables_list() { + $result = $this->query("SHOW TABLES"); + if ($result===false) throw new Exception("MySQL operation failed\n".mysql_error($this->connection)); + + $tables = array(); + while ($table = $result->next()) { + $tables[] = $table[0]; + } + return $tables; + } + + public function fields_list($table) { + $result = $this->query("SHOW COLUMNS FROM `".$table."`"); + if ($result===false) throw new Exception("MySQL operation failed\n".mysql_error($this->connection)); + + $fields = array(); + $id = ""; + while ($field = $result->next()) { + if ($field['Key'] == "PRI") + $id = $field["Field"]; + else + $fields[] = $field["Field"]; + } + return array("fields" => $fields, "key" => $id ); + } public function get_next($res){ $data = $res->next(); |