PageRenderTime 56ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/pokemon/index.queries.inc.php

https://gitlab.com/leduc1984/pokemon-1
PHP | 206 lines | 197 code | 9 blank | 0 comment | 1 complexity | c2dcbfd8720b5f7baf1a544c89adc3ae MD5 | raw file
  1. <?php
  2. $qryPokemon = dbSelectAssoc("
  3. *
  4. ,(select identifier from pokemon_types sub_pt join types sub_t on sub_pt.type_id=sub_t.id where sub_pt.pokemon_id=p.species_id and slot=1) as type1
  5. ,(select identifier from pokemon_types sub_pt join types sub_t on sub_pt.type_id=sub_t.id where sub_pt.pokemon_id=p.species_id and slot=2) as type2
  6. ,(select identifier from abilities sub_a join pokemon_abilities sub_pa on sub_a.id=sub_pa.ability_id where sub_pa.pokemon_id=p.species_id and slot=1) as ability1
  7. ,(select effect from ability_prose sub_ap where local_language_id=".$_COOKIE['language']." and sub_ap.ability_id=(select ability_id from pokemon_abilities sub_pa where sub_pa.pokemon_id=p.species_id and sub_pa.slot=1)) as ability1effect
  8. ,(select short_effect from ability_prose sub_ap where local_language_id=".$_COOKIE['language']." and sub_ap.ability_id=(select ability_id from pokemon_abilities sub_pa where sub_pa.pokemon_id=p.species_id and sub_pa.slot=1)) as ability1effectshort
  9. ,(select identifier from abilities sub_a join pokemon_abilities sub_pa on sub_a.id=sub_pa.ability_id where sub_pa.pokemon_id=p.species_id and slot=2) as ability2
  10. ,(select effect from ability_prose sub_ap where local_language_id=".$_COOKIE['language']." and sub_ap.ability_id=(select ability_id from pokemon_abilities sub_pa where sub_pa.pokemon_id=p.species_id and sub_pa.slot=2)) as ability2effect
  11. ,(select short_effect from ability_prose sub_ap where local_language_id=".$_COOKIE['language']." and sub_ap.ability_id=(select ability_id from pokemon_abilities sub_pa where sub_pa.pokemon_id=p.species_id and sub_pa.slot=2)) as ability2effectshort
  12. ,(select identifier from abilities sub_a join pokemon_abilities sub_pa on sub_a.id=sub_pa.ability_id where sub_pa.pokemon_id=p.species_id and slot=3) as abilityDream
  13. ,(select effect from ability_prose sub_ap where local_language_id=".$_COOKIE['language']." and sub_ap.ability_id=(select ability_id from pokemon_abilities sub_pa where sub_pa.pokemon_id=p.species_id and sub_pa.slot=3 and is_dream=1)) as abilityDreameffect
  14. ,(select short_effect from ability_prose sub_ap where local_language_id=".$_COOKIE['language']." and sub_ap.ability_id=(select ability_id from pokemon_abilities sub_pa where sub_pa.pokemon_id=p.species_id and sub_pa.slot=3 and is_dream=1)) as abilityDreameffectshort
  15. ,(select identifier from egg_groups sub_eg join pokemon_egg_groups sub_peg on sub_eg.id=sub_peg.egg_group_id where sub_peg.species_id=p.species_id order by egg_group_id asc limit 1) as eggGroup1
  16. ,(select identifier from egg_groups sub_eg join pokemon_egg_groups sub_peg on sub_eg.id=sub_peg.egg_group_id where sub_peg.species_id=p.species_id order by egg_group_id desc limit 1) as eggGroup2
  17. ,(select base_stat from pokemon_stats sub_ps where sub_ps.pokemon_id=p.species_id and stat_id=1) as baseHP
  18. ,(select base_stat from pokemon_stats sub_ps where sub_ps.pokemon_id=p.species_id and stat_id=2) as baseAtt
  19. ,(select base_stat from pokemon_stats sub_ps where sub_ps.pokemon_id=p.species_id and stat_id=3) as baseDef
  20. ,(select base_stat from pokemon_stats sub_ps where sub_ps.pokemon_id=p.species_id and stat_id=4) as baseSpAtt
  21. ,(select base_stat from pokemon_stats sub_ps where sub_ps.pokemon_id=p.species_id and stat_id=5) as baseSpDef
  22. ,(select base_stat from pokemon_stats sub_ps where sub_ps.pokemon_id=p.species_id and stat_id=6) as baseSpeed
  23. ,(select sum(base_stat) from pokemon_stats sub_ps where sub_ps.pokemon_id=p.species_id) as baseTotal
  24. from pokemon p
  25. join pokemon_species ps on ps.id=p.species_id
  26. where ps.identifier = '" . $urlPokemon . "'
  27. ");
  28. $qryEvolution = dbSelect("
  29. ps.id,
  30. ps.identifier pokemonName,
  31. pe.evolution_trigger_id,
  32. et.identifier as evolveMethod,
  33. pe.minimum_level,
  34. pe.minimum_happiness,
  35. pe.minimum_beauty,
  36. pe.known_move_id,
  37. pe.time_of_day,
  38. pe.location_id,
  39. it_use.identifier as itemNameUse,
  40. it_held.identifier as itemNameHeld,
  41. g.identifier as genderName,
  42. ps.is_baby
  43. from pokemon_species ps
  44. left outer join pokemon_evolution pe on ps.id=pe.evolved_species_id
  45. left outer join evolution_triggers et on pe.evolution_trigger_id=et.id
  46. left outer join items it_use on pe.trigger_item_id=it_use.id
  47. left outer join items it_held on pe.held_item_id=it_held.id
  48. left outer join genders g on pe.gender_id=g.id
  49. where evolution_chain_id=" . $qryPokemon['evolution_chain_id'] . "
  50. order by ps.is_baby desc,
  51. pe.minimum_level asc"
  52. );
  53. $qryMovesLevelUp = dbSelect("
  54. m.identifier as moveName,
  55. m.power,
  56. m.accuracy,
  57. m.pp,
  58. m.priority,
  59. pm.level,
  60. t.identifier as moveType,
  61. mdc.identifier as moveDamageClass,
  62. mep.short_effect
  63. from pokemon_moves pm
  64. join moves m on pm.move_id=m.id
  65. join pokemon_move_methods pmm on pm.pokemon_move_method_id=pmm.id
  66. join types t on m.type_id=t.id
  67. join move_damage_classes mdc on m.damage_class_id=mdc.id
  68. join move_effect_prose mep on m.effect_id=mep.move_effect_id
  69. and mep.local_language_id=".$_COOKIE['language']."
  70. where version_group_id=".$_COOKIE['version_group_id']."
  71. and pokemon_id=".$qryPokemon['id']."
  72. and pmm.id=1
  73. order by pm.level,
  74. pmm.identifier
  75. ");
  76. $qryMovesLevelUpOtherEvolutions = dbSelect("
  77. m.identifier as moveName,
  78. m.power,
  79. m.accuracy,
  80. m.pp,
  81. m.priority,
  82. pm.level,
  83. t.identifier as moveType,
  84. mdc.identifier as moveDamageClass,
  85. mep.short_effect,
  86. ps.identifier as pokemonName
  87. from pokemon_moves pm
  88. join moves m on pm.move_id=m.id
  89. join pokemon_move_methods pmm on pm.pokemon_move_method_id=pmm.id
  90. join types t on m.type_id=t.id
  91. join move_damage_classes mdc on m.damage_class_id=mdc.id
  92. join move_effect_prose mep on m.effect_id=mep.move_effect_id
  93. and mep.local_language_id=".$_COOKIE['language']."
  94. join pokemon_species ps on pm.pokemon_id=ps.id
  95. where version_group_id=".$_COOKIE['version_group_id']."
  96. and pokemon_id in (select id from pokemon_species sub_p where sub_p.evolution_chain_id=".$qryPokemon['evolution_chain_id'].")
  97. and pokemon_id != ".$qryPokemon['id']."
  98. and m.id not in (
  99. select distinct move_id
  100. from pokemon_moves sub_pm
  101. where sub_pm.pokemon_id=".$qryPokemon['id']."
  102. and sub_pm.version_group_id=".$_COOKIE['version_group_id']."
  103. and sub_pm.pokemon_move_method_id=1
  104. )
  105. and pmm.id=1
  106. order by ps.identifier,
  107. pm.level
  108. ");
  109. $qryMovesMachine = dbSelect("
  110. m.identifier as moveName,
  111. m.power,
  112. m.accuracy,
  113. m.pp,
  114. m.priority,
  115. t.identifier as moveType,
  116. mdc.identifier as moveDamageClass,
  117. mep.short_effect,
  118. ma.machine_number
  119. from pokemon_moves pm
  120. join moves m on pm.move_id=m.id
  121. join pokemon_move_methods pmm on pm.pokemon_move_method_id=pmm.id
  122. join types t on m.type_id=t.id
  123. join move_damage_classes mdc on m.damage_class_id=mdc.id
  124. join move_effect_prose mep on m.effect_id=mep.move_effect_id
  125. and mep.local_language_id=".$_COOKIE['language']."
  126. join machines ma on pm.move_id=ma.move_id
  127. and ma.version_group_id=".$_COOKIE['version_group_id']."
  128. where pm.version_group_id=".$_COOKIE['version_group_id']."
  129. and pm.pokemon_id=".$qryPokemon['id']."
  130. and pmm.id=4
  131. order by ma.machine_number
  132. ");
  133. $qryMovesEgg = dbSelect("
  134. m.identifier as moveName,
  135. m.power,
  136. m.accuracy,
  137. m.pp,
  138. m.priority,
  139. t.identifier as moveType,
  140. mdc.identifier as moveDamageClass,
  141. mep.short_effect
  142. from pokemon_moves pm
  143. join moves m on pm.move_id=m.id
  144. join pokemon_move_methods pmm on pm.pokemon_move_method_id=pmm.id
  145. join types t on m.type_id=t.id
  146. join move_damage_classes mdc on m.damage_class_id=mdc.id
  147. join move_effect_prose mep on m.effect_id=mep.move_effect_id
  148. and mep.local_language_id=".$_COOKIE['language']."
  149. where version_group_id=".$_COOKIE['version_group_id']."
  150. and pokemon_id in (select id from pokemon_species sub_p where sub_p.evolution_chain_id=".$qryPokemon['evolution_chain_id'].")
  151. and pmm.id=2
  152. order by pm.level,
  153. pmm.identifier
  154. ");
  155. $qryMovesMoveTutor = dbSelect("
  156. m.identifier as moveName,
  157. m.power,
  158. m.accuracy,
  159. m.pp,
  160. m.priority,
  161. t.identifier as moveType,
  162. mdc.identifier as moveDamageClass,
  163. mep.short_effect
  164. from pokemon_moves pm
  165. join moves m on pm.move_id=m.id
  166. join pokemon_move_methods pmm on pm.pokemon_move_method_id=pmm.id
  167. join types t on m.type_id=t.id
  168. join move_damage_classes mdc on m.damage_class_id=mdc.id
  169. join move_effect_prose mep on m.effect_id=mep.move_effect_id
  170. and mep.local_language_id=".$_COOKIE['language']."
  171. where version_group_id=".$_COOKIE['version_group_id']."
  172. and pokemon_id=".$qryPokemon['id']."
  173. and pmm.id=3
  174. order by pm.level,
  175. pmm.identifier
  176. ");
  177. $qryLocations = dbSelect("
  178. l.identifier as locationName,
  179. e.min_level,
  180. e.max_level,
  181. es.rarity,
  182. em.identifier as encounterMethodName,
  183. emp.name as encounterMethodNameProse,
  184. ecv.identifier as encounterCondition
  185. from `encounters` e
  186. join `location_areas` la on e.location_area_id=la.id
  187. join `locations` l on la.location_id=l.id
  188. join `encounter_slots` es on e.encounter_slot_id=es.id
  189. and es.version_group_id=".$_COOKIE['version_group_id']."
  190. join `encounter_methods` em on es.encounter_method_id=em.id
  191. join `encounter_method_prose` emp on es.encounter_method_id=emp.encounter_method_id
  192. left outer join `encounter_condition_value_map` ecvm on e.id=ecvm.encounter_id
  193. left outer join `encounter_condition_values` ecv on ecvm.encounter_condition_value_id=ecv.id
  194. where e.pokemon_id=".$qryPokemon['id']."
  195. and version_id=".$_COOKIE['version_id']."
  196. ");
  197. ?>