55 lines
1.5 KiB
PHP
55 lines
1.5 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: Administrator
|
|
* Date: 2014/12/4
|
|
* Time: 11:31
|
|
*/
|
|
|
|
namespace Westdc\Visual;
|
|
|
|
|
|
class DataTableControl extends Database{
|
|
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
public function readSchema(){
|
|
$sql = "SELECT distinct(schemaname) FROM pg_tables WHERE tableowner='gis'";
|
|
$rs = $this->db->query($sql);
|
|
|
|
$rows = $rs->fetchAll(\PDO::FETCH_ASSOC);
|
|
|
|
foreach($rows as $k=>$v)
|
|
{
|
|
yield $v['schemaname'];
|
|
}
|
|
}
|
|
|
|
public function readTables($schema = NULL)
|
|
{
|
|
if(empty($schema))
|
|
{
|
|
$sql = "SELECT schemaname||'.'||tablename as tablename FROM pg_tables WHERE tableowner='gis' ORDER BY tablename ";
|
|
$rs = $this->db->query($sql);
|
|
|
|
$row = $rs->fetchAll(\PDO::FETCH_COLUMN);
|
|
return $row;
|
|
}
|
|
|
|
$sql = "SELECT tablename as tablename FROM pg_tables WHERE tableowner='gis' AND schemaname='".$schema."' ORDER BY tablename";
|
|
$rs = $this->db->query($sql);
|
|
return $rs->fetchAll(\PDO::FETCH_ASSOC);
|
|
}
|
|
|
|
public function readFields($tablename,$identity = "")
|
|
{
|
|
$st=explode('.',$tablename);
|
|
$sql = "select * from INFORMATION_SCHEMA.COLUMNS where table_schema='".$st[0]."' and TABLE_NAME='".$st[1]."'";
|
|
$rs = $this->db->query($sql);
|
|
return $rs->fetchAll(\PDO::FETCH_ASSOC);
|
|
}
|
|
|
|
}
|