Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Obiekty
Forum PHP.pl > Forum > PHP > Object-oriented programming
CyberBob
otrzymuje od serwa komunikat:
Kod
Fatal error: Call to a member function close() on a non-object in D:\serwer\www\tpscorp.info\idawell.php on line 71

Oto pliki, w których moga być błędy...
  1. <?php
  2. #idawell.php
  3. function __autoload( $module_name )
  4. {
  5. require_once( $root_path. 'modules/' .$module_name. '.php' );
  6. }
  7.  
  8. class idawell
  9. {
  10. public function __construct( )
  11. {
  12. $this -> load_Config( );
  13. $this -> idawell_initialisation( );
  14. // $this -> decode_URL( );
  15.  
  16.  
  17. if( $config['update_Info'] <> '' )
  18. die( $config['update_Info'] );
  19.  
  20. $this -> tpl -> template_dir = $root_path . 'templates/';
  21. $this -> tpl -> compile_dir = $root_path . 'templates/compiled/';
  22. $this -> tpl -> config_dir = $root_path . 'templates/configs/';
  23. $this -> tpl -> cache_dir = $root_path . 'templates/cache/';
  24.  
  25. $this -> load_activeModules( );
  26. }
  27.  
  28. public function load_Config( )
  29. {
  30. require_once( 'config.php' );
  31. }
  32.  
  33. public function idawell_initialisation( )
  34. {
  35. $GLOBALS['mod_mysql'] = new mod_mysql( $GLOBALS['config']['dbHost'], $GLOBALS['config']['dbUser'], $GLOBALS['config']['dbPass'], $GLOBALS['config']['dbName'] );
  36. $this -> db = $GLOBALS['mod_mysql'];
  37.  
  38. require_once( $root_path . 'modules/smarty/Smarty.class.php' );
  39. $GLOBALS['mod_smarty'] = new Smarty;
  40. $this -> tpl = $GLOBALS['mod_smarty'];
  41. }
  42.  
  43. public function load_activeModules( )
  44. {
  45. /* $this -> modules_List = array( 'test', 'test2' );
  46.  
  47. foreach( $this -> modules_List as $var )
  48. {
  49. $GLOBALS[$var] = new $var;
  50. }
  51. */ }
  52.  
  53. public function module_publish( )
  54. {
  55. /* $this -> db = $GLOBALS['mod_mysql'];
  56. $this -> tpl = $GLOBALS['mod_smarty'];
  57.  
  58. foreach( $modules_List as $var )
  59. {
  60. $this -> $var = $GLOBALS[$var];
  61. }
  62. */ }
  63.  
  64. public function __destruct( )
  65. {
  66. $this -> db -> close( );
  67. }
  68. }
  69. $idawell = new idawell;
  70. ?>

  1. <?php
  2. # mod_mysql.php
  3.  
  4. class mod_mysql extends idawell
  5. {
  6. private $connect_id;
  7. private $query_result;
  8. private $row = array( );
  9. private $rowset = array( );
  10. public $num_queries = 0;
  11.  
  12. /**
  13.  * Polaczenie z serwerem sql i wybranie bazy danych
  14.  */
  15. public function __construct( $sql_server, $sql_user, $sql_password, $database, $persistency = False )
  16. { 
  17.  $this -> persistency = $persistency;
  18. $this -> user = $sql_user;
  19. $this -> password = $sql_password;
  20. $this -> server = $sql_server;
  21. $this -> dbname = $database;
  22.  
  23. $this -> connect_id = ( $this -> persistency ) ? @mysql_pconnect( $this -> server, $this -> user, $this -> password ) : @mysql_connect( $this -> server, $this -> user, $this -> password );
  24.  
  25. if( $this -> connect_id )
  26. {
  27. if( $database != '' )
  28. {
  29. $this -> dbname = $database;
  30. $dbselect = @mysql_select_db( $this -> dbname );
  31.  
  32. if( !$dbselect )
  33. {
  34. $this -> close( );
  35. die( 'Wystapil blad podczas wybierania bazy danych' );
  36. }
  37. }
  38. return $this -> connect_id;
  39. }
  40. die( 'Wystapil blad w polaczeniu z serwerem MySQL' );
  41. }
  42.  
  43. /**
  44.  * Zamyka polaczenie z serwerem sql i zwalnia pamiec zajmowana przez wyniki
  45.  */
  46. public function close( )
  47. {
  48. if( $this -> query_result )
  49. {
  50. $this -> free_result( );
  51. }
  52.  
  53. return @mysql_close( $this -> connect_id );
  54. }
  55.  
  56. /**
  57.  * Zwalnia pamiec zajmowana przez wynik
  58.  */
  59. private function free_result( $query_result = '' )
  60. {
  61. $query_result = ( empty($query_result) ) ? $this -> query_result : $query_result;
  62.  
  63. if ( $query_result )
  64. {
  65. unset( $this -> row[$query_result] );
  66. unset( $this -> rowset[$query_result] );
  67. @mysql_free_result( $query_result );
  68.  
  69. return True;
  70. }
  71. return False;
  72. }
  73.  
  74. /**
  75.  * Zwraca tresc lub numer ostatniego komunikatu o bledzie
  76.  */
  77. public function error( $what = 'message' )
  78. {
  79. return ( $what == 'message' ) ? mysql_error( $this -> connect_id ) : mysql_errno( $this -> connect_id );
  80. }
  81. }
  82.  
  83. ?>

Wiem, że troche namieszałem, ale chciałbym w taki sposób to rozwiązać, byłbym wdzięczny za pomoc...
crash
A gdzie masz utworzenie obiektu db?
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.