diff options
author | Christian A. Weber | 2016-03-16 13:42:55 +0100 |
---|---|---|
committer | Christian A. Weber | 2016-03-16 13:44:03 +0100 |
commit | f704cbefbebd2e6ba982935118d7d84fdcb3c3b7 (patch) | |
tree | d9f7c2881b37516fb519ad2c070d127873c8f3e0 | |
parent | 7f25197f10a29c0265d110170d33766069e7715c (diff) | |
download | itools-f704cbefbebd2e6ba982935118d7d84fdcb3c3b7.tar.gz itools-f704cbefbebd2e6ba982935118d7d84fdcb3c3b7.tar.bz2 itools-f704cbefbebd2e6ba982935118d7d84fdcb3c3b7.zip |
add function dbi::tables() to get a list of all tables of a db
-rw-r--r-- | it_dbi.class | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/it_dbi.class b/it_dbi.class index 1b749eb..d498090 100644 --- a/it_dbi.class +++ b/it_dbi.class @@ -115,10 +115,8 @@ function createclasses($p = array()) if (!$tables = $state['tables']) { - for ($tables = array(), $res = $dbi->query('SHOW TABLES', $p); $row = mysqli_fetch_row($res);) - $tables[] = $row[0]; - - $state = it_dbi::_state_get($dbid); # State could have been modified by query above + $tables = $dbi->tables($p); + $state = it_dbi::_state_get($dbid); # State could have been modified by $db->ables() call $state['tables'] = $tables; it_dbi::_state_put($dbid, $state); } @@ -422,6 +420,18 @@ function _write_pre_process(&$tags, $command) # NOPHPLINT /** + * Return an array of all tables of this database + */ +function tables($p = array()) +{ + for ($qr = $this->query('SHOW TABLES', $p); $row = mysqli_fetch_row($qr);) + $result[] = $row[0]; + + return (array)$result; +} + + +/** * Clear record */ function clear($pp = true) |