Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL][PHP]Klasa do obsługi MySQL
o2w5n778
post
Post #1





Grupa: Zarejestrowani
Postów: 235
Pomógł: 0
Dołączył: 10.12.2009

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


Czy używania takiej klasy ma jakiś sens, i czy jest ona dobrze napisana?
  1. class mysql{
  2.  
  3. public $result;
  4.  
  5. public $results;
  6.  
  7. function __construct($dbhost, $dbuser, $dbpass, $dbname){
  8. $connectc = mysql_connect($dbhost, $dbuser, $dbpass) or die (mysql_error());
  9. $connects = mysql_select_db($dbname) or die (mysql_error());
  10. }
  11.  
  12. function __destruct(){
  13. }
  14.  
  15. function query($query){
  16. $this->result = mysql_query($query);
  17. if($this->result){
  18. return $this->result;
  19. } else {
  20. }
  21. }
  22.  
  23. function fetch_array(){
  24. return mysql_fetch_array($this->result);
  25. }
  26.  
  27. function fetch_array_all(){
  28. $results = array();
  29. while($return = mysql_fetch_array($this->result)){
  30. $results[] = $return;
  31. }
  32. return $results;
  33. }
  34.  
  35. function num_rows(){
  36. return mysql_num_rows($this->result);
  37. }
  38.  
  39. }
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 26.09.2025 - 07:10