sql = new $class; } // -------------------------------------------------------------------------- /** * Connect to a different database * * @param string $name */ public function switch_db($name) { // @todo Implement return FALSE; } // -------------------------------------------------------------------------- /** * Empty a table * * @param string $table */ public function truncate($table) { $sql = 'TRUNCATE "' . $table . '"'; $this->query($sql); } // -------------------------------------------------------------------------- /** * Get list of databases for the current connection * * @return array */ public function get_dbs() { $sql = <<query($sql); return db_filter($res->fetchAll(PDO::FETCH_ASSOC), 'datname'); } // -------------------------------------------------------------------------- /** * Get the list of tables for the current db * * @return array */ public function get_tables() { $sql = <<query($sql); return db_filter($res->fetchAll(PDO::FETCH_ASSOC), 'tablename'); } // -------------------------------------------------------------------------- /** * Get the list of system tables * * @return array */ public function get_system_tables() { $sql = <<query($sql); return db_filter($res->fetchAll(PDO::FETCH_ASSOC), 'tablename'); } // -------------------------------------------------------------------------- /** * Get a list of schemas, either for the current connection, or * for the current datbase, if specified. * * @return array */ public function get_schemas() { $sql = <<query($sql); $schemas = $res->fetchAll(PDO::FETCH_ASSOC); return db_filter($schemas, 'schemaname'); } // -------------------------------------------------------------------------- /** * Get a list of views for the current db * * @return array */ public function get_views() { $sql = <<query($sql); return db_filter($res->fetchAll(PDO::FETCH_ASSOC), 'viewname'); } // -------------------------------------------------------------------------- /** * Get a list of sequences for the current db * * @return array */ public function get_sequences() { $sql = <<query($sql); return db_filter($res->fetchAll(PDO::FETCH_ASSOC), 'relname'); } // -------------------------------------------------------------------------- /** * Return list of custom functions for the current database * * @return array */ public function get_functions() { // @todo Implement return FALSE; } // -------------------------------------------------------------------------- /** * Retrun list of stored procedures for the current database * * @return array */ public function get_procedures() { $sql = <<query($sql); return db_filter($res->fetchAll(PDO::FETCH_ASSOC), 'routine_name'); } // -------------------------------------------------------------------------- /** * Return list of triggers for the current database * * @return array */ public function get_triggers() { $sql = <<query($sql); return $res->fetchAll(PDO::FETCH_ASSOC); } // -------------------------------------------------------------------------- /** * Return the number of rows returned for a SELECT query * * @return int */ public function num_rows() { return (isset($this->statement)) ? $this->statement->rowCount : FALSE; } // -------------------------------------------------------------------------- /** * Create an SQL backup file for the current database's structure * * @return string */ public function backup_structure() { // @todo Implement Backup function return ''; } // -------------------------------------------------------------------------- /** * Create an SQL backup file for the current database's data * * @return string */ public function backup_data() { // @todo Implement Backup function return ''; } } //End of pgsql.php