Guest User

Untitled

a guest
Apr 20th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.74 KB | None | 0 0
  1. appmodelsRecipe::findOne(15);
  2.  
  3. SELECT
  4. d.nspname AS table_schema,
  5. c.relname AS table_name,
  6. a.attname AS column_name,
  7. t.typname AS data_type,
  8. a.attlen AS character_maximum_length,
  9. pg_catalog.col_description(c.oid, a.attnum) AS column_comment,
  10. a.atttypmod AS modifier,
  11. a.attnotnull = false AS is_nullable,
  12. CAST(pg_get_expr(ad.adbin, ad.adrelid) AS varchar) AS column_default,
  13. coalesce(pg_get_expr(ad.adbin, ad.adrelid) ~ 'nextval',false) AS is_autoinc,
  14. array_to_string((select array_agg(enumlabel) from pg_enum where enumtypid=a.atttypid)::varchar[],',') as enum_values,
  15. CASE atttypid
  16. WHEN 21 /*int2*/ THEN 16
  17. WHEN 23 /*int4*/ THEN 32
  18. WHEN 20 /*int8*/ THEN 64
  19. WHEN 1700 /*numeric*/ THEN
  20. CASE WHEN atttypmod = -1
  21. THEN null
  22. ELSE ((atttypmod - 4) >> 16) & 65535
  23. END
  24. WHEN 700 /*float4*/ THEN 24 /*FLT_MANT_DIG*/
  25. WHEN 701 /*float8*/ THEN 53 /*DBL_MANT_DIG*/
  26. ELSE null
  27. END AS numeric_precision,
  28. CASE
  29. WHEN atttypid IN (21, 23, 20) THEN 0
  30. WHEN atttypid IN (1700) THEN
  31. CASE
  32. WHEN atttypmod = -1 THEN null
  33. ELSE (atttypmod - 4) & 65535
  34. END
  35. ELSE null
  36. END AS numeric_scale,
  37. CAST(
  38. information_schema._pg_char_max_length(information_schema._pg_truetypid(a, t), information_schema._pg_truetypmod(a, t))
  39. AS numeric
  40. ) AS size,
  41. a.attnum = any (ct.conkey) as is_pkey
  42. FROM
  43. pg_class c
  44. LEFT JOIN pg_attribute a ON a.attrelid = c.oid
  45. LEFT JOIN pg_attrdef ad ON a.attrelid = ad.adrelid AND a.attnum = ad.adnum
  46. LEFT JOIN pg_type t ON a.atttypid = t.oid
  47. LEFT JOIN pg_namespace d ON d.oid = c.relnamespace
  48. LEFT join pg_constraint ct on ct.conrelid=c.oid and ct.contype='p'
  49. WHERE
  50. a.attnum > 0 and t.typname != ''
  51. and c.relname = 'cook_recipes'
  52. and d.nspname = 'public'
  53. ORDER BY
  54. a.attnum;
  55.  
  56. SELECT * FROM "cook_recipes" WHERE "id"=15
  57.  
  58. select
  59. ct.conname as constraint_name,
  60. a.attname as column_name,
  61. fc.relname as foreign_table_name,
  62. fns.nspname as foreign_table_schema,
  63. fa.attname as foreign_column_name
  64. from
  65. (SELECT ct.conname, ct.conrelid, ct.confrelid, ct.conkey, ct.contype, ct.confkey, generate_subscripts(ct.conkey, 1) AS s
  66. FROM pg_constraint ct
  67. ) AS ct
  68. inner join pg_class c on c.oid=ct.conrelid
  69. inner join pg_namespace ns on c.relnamespace=ns.oid
  70. inner join pg_attribute a on a.attrelid=ct.conrelid and a.attnum = ct.conkey[ct.s]
  71. left join pg_class fc on fc.oid=ct.confrelid
  72. left join pg_namespace fns on fc.relnamespace=fns.oid
  73. left join pg_attribute fa on fa.attrelid=ct.confrelid and fa.attnum = ct.confkey[ct.s]
  74. where
  75. ct.contype='f'
  76. and c.relname='cook_recipes'
  77. and ns.nspname='public'
  78. order by
  79. fns.nspname, fc.relname, a.attnum
  80.  
  81. @334 строка, метод `findColumns()`
  82.  
  83. @219 строка, метод `findConstraints()`
  84.  
  85. @157 строка, метод `loadTableSchema()`
  86.  
  87. return [
  88. 'components' => [
  89. 'db' => [
  90. 'class' => 'yiidbConnection',
  91. //...
  92. 'enableSchemaCache' => true,
  93. // 'schemaCacheDuration' => 3600,
  94.  
  95. ],
  96. ]
  97. ];
  98.  
  99. return [
  100. 'components' => [
  101. 'db' => [
  102. 'class' => 'yiidbConnection',
  103. 'enableSchemaCache' => true,
  104. 'schemaCacheDuration' => 3600,
  105. ],
  106. ],
  107. //
  108. 'cache' => [
  109. 'class' => 'yiicachingMemCache',
  110. // или 'class' => 'yiicachingFileCache',
  111. ],
  112. ];
  113.  
  114. 'log' => [
  115. 'targets' => [[
  116. 'class' => 'yiilogFileTarget',
  117. 'levels' => ['error', 'warning'],
  118. 'logFile' => '@runtime/logs/app.log'
  119. ]]
  120. ]
  121.  
  122. chmod 0777 -R runtime
Add Comment
Please, Sign In to add comment