Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> mysqli i skrypt obsługi baz danych, problem z fetch_array()
ignition
post
Post #1





Grupa: Zarejestrowani
Postów: 36
Pomógł: 0
Dołączył: 14.06.2004

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


Zrobiłem sobie taką klasę obsługi baz danych( jak na razie mysqli), aby w przyszłości lepiej mi się aktualizowało kod:
  1. <?php
  2. class cristalquery
  3. {
  4. protected $dbConfig = array();
  5. public $mainQuery;
  6. public $query = array();
  7. public $db;
  8.  
  9. function __construct( $dbParameter )
  10. {
  11. if( is_array( $dbParameter ))
  12. {
  13. $this->db = new mysqli( $dbParameter['host'], $dbParameter['user'], $dbParameter['password'] );
  14. mysql_select_db( $dbParameter['db'] );
  15. }
  16. else 
  17. {
  18. $value = func_get_args();
  19. $this->db = new mysqli( $value[0], $value[1], $value[2], $value[3] );
  20. }
  21. }
  22.  
  23. function __set( $key, $value )
  24. {
  25. $this->query( $value, $key );
  26. }
  27.  
  28. function query( $query, $name = '' )
  29. {
  30. if( $name )
  31. {
  32. return $this->query[&#092;"$name\"] &= $this->db->query(\"$query\");
  33. }
  34. else 
  35. {
  36. return $this->mainQuery = $this->db->query(&#092;"$query\");
  37. }
  38. }
  39.  
  40. function fetchArray( $name = '', $typeArray = 'MYSQLI_ASSOC' )
  41. {
  42. if( $name )
  43. {
  44. return $this->query[&#092;"$name\"]->fetch_array( $typeArray );
  45. }
  46. else 
  47. {
  48. return $this->mainQuery->fetch_array( $typeArray );
  49. }
  50. }
  51. }
  52.  
  53. ?>

...i wyskakują mi błedy
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
bela
post
Post #2


Administrator PHPedia.pl


Grupa: Developerzy
Postów: 1 102
Pomógł: 2
Dołączył: 14.09.2003

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


a moglbys nam powiedziec jakie to są błędy ?

oddziel klase do obslugi bazy od rezultatu (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)

Ten post edytował bela_666 29.11.2004, 21:01:09
Go to the top of the page
+Quote Post
ignition
post
Post #3





Grupa: Zarejestrowani
Postów: 36
Pomógł: 0
Dołączył: 14.06.2004

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


zazwyczaj błąd polega na tym że tworząc zapytanie "$this->db->query("$query")" nie chce uznać daną zmienną jako obiekt
Go to the top of the page
+Quote Post

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: 23.08.2025 - 20:42