query($sql); } /** * Get list of databases for the current connection * * @return array */ function get_dbs() { $sql = "SELECT datname FROM pg_database WHERE datname NOT IN ('template0','template1') ORDER BY 1"; $res = $this->query($sql); $dbs = $res->fetchAll(PDO::FETCH_ASSOC); return $dbs; } /** * Get the list of tables for the current db * * @return array */ function get_tables() { $sql = 'SELECT "tablename" FROM "pg_tables" WHERE "tablename" NOT LIKE pg\_% AND "tablename" NOT LIKE sql\%'; $res = $this->query($sql); $dbs = $res->fetchAll(PDO::FETCH_ASSOC); return $dbs; } /** * Get a list of views for the current db * * @return array */ function get_views() { $sql = 'SELECT "viewname" FROM "pg_views" WHERE viewname NOT LIKE pg\_%'; $res = $this->query($sql); $views = $res->fetchAll(PDO::FETCH_ASSOC); return $views; } } /** * PostgreSQL DB Structure manipulation class */ class pgSQL_manip extends pgSQL { function __construct($dsn, $username=null, $password=null, $options=array()) { parent::__construct($dsn, $username, $password, $options); } }