Advertisement
Guest User

L2j SQL QUERY Universal By Ivan Pires

a guest
Aug 16th, 2015
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. function info_table($tabela,$coluna){
  2. global $conn;
  3. $tabela = strtolower($tabela);
  4. $coluna = strtolower($coluna);
  5. $stmt = $conn->prepare('SHOW COLUMNS FROM '.$tabela);
  6. if($stmt->execute()){
  7. if($coluna == "accesslevel"){
  8. while($row = $stmt->fetch(\PDO::FETCH_ASSOC)){
  9. if(preg_match("/^access/i", $row["Field"]))
  10. return $row["Field"];
  11. }
  12. }
  13. if($coluna == "charid"){
  14. if($tabela == "characters" || $tabela == "heroes" || $tabela == "olympiad_nobles"){
  15. while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
  16. if ($row["Key"] == "PRI")
  17. return $row["Field"];
  18. }
  19. }else{
  20. $row = $stmt->fetch(\PDO::FETCH_ASSOC);
  21. return $row["Field"];
  22. }
  23. }
  24. }
  25. return null;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement