DbSqlAdapterPgsql.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. class LtDbSqlAdapterPgsql implements LtDbSqlAdapter
  3. {
  4. public function setCharset($charset)
  5. {
  6. return "SET client_encoding TO '$charset'";
  7. }
  8. public function setSchema($schema)
  9. {
  10. return "SET search_path TO $schema";
  11. }
  12. public function beginTransaction()
  13. {
  14. return "";
  15. }
  16. public function commit()
  17. {
  18. return "";
  19. }
  20. public function rollBack()
  21. {
  22. return "";
  23. }
  24. public function showSchemas($database)
  25. {
  26. }
  27. public function showTables($schema)
  28. {
  29. return "SELECT case when n.nspname='public' then c.relname else n.nspname||'.'||c.relname end as relname
  30. FROM pg_class c join pg_namespace n on (c.relnamespace=n.oid)
  31. WHERE c.relkind = 'r'
  32. AND n.nspname NOT IN ('information_schema','pg_catalog')
  33. AND n.nspname NOT LIKE 'pg_temp%'
  34. AND n.nspname NOT LIKE 'pg_toast%'
  35. ORDER BY relname";
  36. }
  37. public function showFields($table)
  38. {
  39. return "SELECT a.attnum, a.attname AS field, t.typname AS type,
  40. format_type(a.atttypid, a.atttypmod) AS complete_type,
  41. a.attnotnull AS isnotnull,
  42. ( SELECT 't' FROM pg_index
  43. WHERE c.oid = pg_index.indrelid
  44. AND pg_index.indkey[0] = a.attnum
  45. AND pg_index.indisprimary = 't') AS pri,
  46. (SELECT pg_attrdef.adsrc FROM pg_attrdef
  47. WHERE c.oid = pg_attrdef.adrelid
  48. AND pg_attrdef.adnum=a.attnum) AS default
  49. FROM pg_attribute a, pg_class c, pg_type t
  50. WHERE c.relname = '$table'
  51. AND a.attnum > 0
  52. AND a.attrelid = c.oid
  53. AND a.atttypid = t.oid
  54. ORDER BY a.attnum";
  55. }
  56. public function limit($limit, $offset)
  57. {
  58. return " LIMIT $limit OFFSET $offset";
  59. }
  60. public function getSchemas($queryResult)
  61. {
  62. }
  63. public function getTables($queryResult)
  64. {
  65. }
  66. public function getFields($queryResult)
  67. {
  68. }
  69. public function detectQueryType($sql)
  70. {
  71. }
  72. }