Guest User

Untitled

a guest
Aug 14th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. <?php
  2. class database_abc
  3. {
  4. var $server,
  5. $host,
  6. $user,
  7. $password,
  8. $database;
  9.  
  10. function __construct($db_name = '', $db_password = '', $db_user = '', $db_host = 'localhost', $debug = '')
  11. {
  12. $this->host = $db_host;
  13. $this->user = $db_user;
  14. $this->password = $db_password;
  15. $this->database = $db_name;
  16.  
  17. $this->open();
  18. }
  19.  
  20. function open()
  21. {
  22. $this->server = @mysql_connect($this->host, $this->user, $this->password) or die("Couldn't connect to SQL server");
  23. @mysql_select_db($this->database, $this->server);
  24. }
  25.  
  26. function query($sql, $debug = 0)
  27. {
  28.  
  29. if($debug)
  30. echo "database/query :<strong>$sql</strong>:<br>n";
  31.  
  32.  
  33. $result = @mysql_query($sql, $this->server);
  34.  
  35. if( ($sql[0] == 'i') || ($sql[0] == 'I') )
  36. return mysql_insert_id();
  37.  
  38. while( $row = @mysql_fetch_array($result) )
  39. $data[] = $row;
  40.  
  41.  
  42. if(isset($data)){
  43. return $data;
  44. }
  45.  
  46. }
  47.  
  48. function queryItem($sql, $debug = 0)
  49. {
  50. $result = $this->query($sql." LIMIT 0,1", $debug);
  51. return $result[0][0];
  52. }
  53. };
  54.  
  55.  
  56. $db = new database_abc("qwerty", "admin", "root", "localhost");
  57.  
  58. ?>
Add Comment
Please, Sign In to add comment