Advertisement
Guest User

Untitled

a guest
Sep 28th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. <?php class query_sql {
  2. protected static $conect;
  3. private function __construct() {
  4.  
  5. $mysql_host = "";
  6. $mysql_base = "";
  7. $mysql_user = "";
  8. $mysql_pass = "";
  9.  
  10. try { self::$conect = new PDO("mysql:host=" . $mysql_host . "; dbname=" . $mysql_base, $mysql_user, $mysql_pass);
  11. self::$conect -> setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  12. self::$conect -> exec("set names utf8");
  13. $conect = null; }
  14.  
  15. catch(PDOException $error) {
  16. echo $error -> getMessage(); } }
  17.  
  18. public static function conect_sql() {
  19. if (!self::$conect) {
  20. new query_sql; }
  21. return self::$conect; } }
  22.  
  23. $bind_sql = query_sql::conect_sql(); ?>
  24.  
  25. $mysql_host = "";
  26. $mysql_base = "";
  27. $mysql_user = "";
  28. $mysql_pass = "";
  29.  
  30. <?php $list_information = $bind_sql -> prepare("SELECT user_email, user_name FROM usuarios WHERE user_email = :user_email LIMIT 1");
  31. $list_information -> bindValue(":user_email", "@");
  32. $list_information -> execute();
  33. $list_information = $list_information -> fetchAll(); ?>
  34.  
  35. <?php $compare_information = $bind_sql -> prepare("SELECT user_email, user_name FROM usuarios WHERE user_email = :user_email AND user_name = :user_name LIMIT 1");
  36. $statement_array = array(":user_email" => "@", ":user_name" => "*");
  37. foreach($statement_array as $array_key => $array_value) {
  38. $compare_information -> bindValue($array_key, $array_value); }
  39. $compare_information -> execute();
  40. $compare_information = $compare_information -> fetchAll(); ?>
  41.  
  42. <?php foreach($list_information as $list_information) {
  43. echo $list_information["user_email"] . " | " . $list_information["user_name"]; } ?>
  44.  
  45. <?php foreach($compare_information as $compare_information) {
  46. echo $compare_information["user_email"] . " | " . $compare_information["user_name"]; } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement