Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Zliczanie wykonanych zapytań.
szarobury
post 29.08.2009, 18:14:49
Post #1





Grupa: Zarejestrowani
Postów: 15
Pomógł: 0
Dołączył: 11.08.2009

Ostrzeżenie: (0%)
-----


Witam sterownik bazy danych i chciałbym wprowadzić zliczanie zapytań sql, lecz nie wiem jak, mógłbym liczyć na pomoc? smile.gif
  1. <?
  2. /*
  3. |----------------------------------------
  4. | DATABASE CLASS
  5. |----------------------------------------
  6. |
  7. */
  8.  
  9. class Database {
  10.  
  11. public $connection;
  12.  
  13. function __construct($host, $name, $pass) {
  14. $this->connection = mysql_connect($host, $name, $pass);
  15. return $this->connection;
  16. }
  17. function error($type)
  18. {
  19. $text = '<h2>MySQL Error</h2>' . "\n";
  20. switch($type)
  21. {
  22. case 'dbselect':
  23. $text .= 'An error occurred when choosing database';
  24. break;
  25.  
  26. case 'query':
  27. $text .= 'An error occurred when executing SQL queries';
  28. break;
  29.  
  30. }
  31. $text .= '!<hr>MySQL said: <i>' . mysql_error() . '</i>';
  32. die($text);
  33. } // one of the above errors appear when the parser encounters an error on its way
  34.  
  35. function select_db( $db_name) {
  36.  
  37. return mysql_select_db( $db_name) or die( $this->error('dbselect'));
  38. } // Select the database
  39.  
  40.  
  41. function query($query) {
  42. return mysql_query($query);
  43. } // SQL query execution {free queries}
  44.  
  45.  
  46. function insert( $into, $set, $free) {
  47.  
  48. return mysql_query("INSERT INTO $into SET $set $free");
  49. } // SQL query execution
  50.  
  51.  
  52. function select( $s, $from, $free='') {
  53.  
  54. return mysql_query("SELECT $s FROM $from $free");
  55. } // SQL query execution
  56.  
  57.  
  58. function update( $from, $free) {
  59.  
  60. return mysql_query("UPDATE $from SET $free");
  61. } // SQL query execution
  62.  
  63.  
  64. function delete( $from, $free) {
  65.  
  66. return mysql_query("DELETE FROM $from $free");
  67. } // SQL query execution
  68.  
  69.  
  70. function fetch_assoc( $assoc) {
  71.  
  72. return mysql_fetch_assoc( $assoc);
  73. } // download records into assoc table
  74.  
  75.  
  76. function num_rows( $num_rows) {
  77.  
  78. return mysql_num_rows( $num_rows);
  79. } // count records
  80.  
  81. function fetch_array( $array) {
  82.  
  83. return mysql_fetch_array( $array);
  84. } // download records into array table
  85.  
  86.  
  87. function __destruct() {
  88. return mysql_close($this->connection);
  89. }
  90. }
  91.  
  92.  
  93. ?>
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 05:32