$tablename = $xmldb_table->getName($xmldb_table);
/// Fetch all the columns in the table
- if (!$columns = $this->mdb->get_columns($tablename, false)) {
+ if (!$columns = $this->mdb->get_columns($tablename)) {
return array();
}
* Return tables in database WITHOUT current prefix
* @return array of table names in lowercase and without prefix
*/
- public function get_tables() {
+ public function get_tables($usecache=true) {
$this->query_start("--adodb-MetaTables", null, SQL_QUERY_AUX);
$metatables = $this->adodb->MetaTables();
$this->query_end(true);
* @throws dml_exception if error
*/
public function change_database_structure($sql) {
- $this->reset_columns();
+ $this->reset_caches();
$this->query_start($sql, null, SQL_QUERY_STRUCTURE);
$rs = $this->adodb->Execute($sql);
protected $database_manager;
protected $columns = array(); // I wish we had a shared memory cache for this :-(
+ protected $tables = null;
// db connection options
protected $dbhost;
$this->database_manager = null;
}
$this->columns = array();
+ $this->tables = null;
}
/**
* Return tables in database WITHOUT current prefix
* @return array of table names in lowercase and without prefix
*/
- public abstract function get_tables();
+ public abstract function get_tables($usecache=true);
/**
* Return table indexes - everything lowercased
* @param string $table - empty means all, or one if name of table given
* @return void
*/
- public function reset_columns() {
+ public function reset_caches() {
$this->columns = array();
+ $this->tables = null;
}
/**
* Return tables in database WITHOUT current prefix
* @return array of table names in lowercase and without prefix
*/
- public function get_tables() {
- $tables = array();
+ public function get_tables($usecache=true) {
+ if ($usecache and $this->tables !== null) {
+ return $this->tables;
+ }
+ $this->tables = array();
$sql = "SHOW TABLES";
$this->query_start($sql, null, SQL_QUERY_AUX);
$result = $this->mysqli->query($sql);
}
$tablename = substr($tablename, strlen($this->prefix));
}
- $tables[$tablename] = $tablename;
+ $this->tables[$tablename] = $tablename;
}
$result->close();
}
- return $tables;
+ return $this->tables;
}
/**
* @throws dml_exception if error
*/
public function change_database_structure($sql) {
- $this->reset_columns();
+ $this->reset_caches();
$this->query_start($sql, null, SQL_QUERY_STRUCTURE);
$result = $this->mysqli->query($sql);
* Return tables in database WITHOUT current prefix
* @return array of table names in lowercase and without prefix
*/
- public function get_tables() {
+ public function get_tables($usecache=true) {
$tables = array();
$prefix = str_replace('_', "\\_", strtoupper($this->prefix));
$sql = "SELECT TABLE_NAME
* @throws dml_exception if error
*/
public function change_database_structure($sql) {
- $this->reset_columns();
+ $this->reset_caches();
$this->query_start($sql, null, SQL_QUERY_STRUCTURE);
$stmt = $this->parse_query($sql);
$this->debug_query($sql);
}
$this->pdb->exec($sql);
- $this->reset_columns();
+ $this->reset_caches();
return true;
} catch (PDOException $ex) {
$this->lastError = $ex->getMessage();
* Return tables in database WITHOUT current prefix
* @return array of table names in lowercase and without prefix
*/
- public function get_tables() {
- $tables = array();
+ public function get_tables($usecache=true) {
+ if ($usecache and $this->tables !== null) {
+ return $this->tables;
+ }
+ $this->tables = array();
$prefix = str_replace('_', '\\\\_', $this->prefix);
$sql = "SELECT tablename
FROM pg_catalog.pg_tables
continue;
}
$tablename = substr($tablename, strlen($this->prefix));
- $tables[$tablename] = $tablename;
+ $this->tables[$tablename] = $tablename;
}
pg_free_result($result);
}
- return $tables;
+ return $this->tables;
}
/**
* @throws dml_exception if error
*/
public function change_database_structure($sql) {
- $this->reset_columns();
+ $this->reset_caches();
$this->query_start($sql, null, SQL_QUERY_STRUCTURE);
$result = pg_query($this->pgsql, $sql);
public function get_server_info(){}
protected function allowed_param_types(){}
public function get_last_error(){}
- public function get_tables(){}
+ public function get_tables($usecache=true){}
public function get_indexes($table){}
public function get_columns($table, $usecache=true){}
public function set_debug($state){}
* Return tables in database WITHOUT current prefix
* @return array of table names in lowercase and without prefix
*/
- public function get_tables() {
+ public function get_tables($usecache=true) {
$tables = array();
$sql = 'SELECT name FROM sqlite_master WHERE type="table" UNION ALL SELECT name FROM sqlite_temp_master WHERE type="table" ORDER BY name';