|
|||||||
| PHP Discussion and technical support for using and deploying PHP based websites. |
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
OOP Class can't close connection
I am trying to write a function that closes the connection created in the following class:
PHP Code:
PHP Code:
|
|
#2
|
||||
|
||||
|
Well, you need to call it for it to run. If you want it called automatically at the end of execution (which is not necessary btw wince PHP will close the connection for you) you could call it from a destructor method.
Also you are assigning the result of the connect method to a variable but the method doesn't return anything. You might also want to consider storing the link identifier as a class property instead of passing it around as an argument to methods. Currently you could only ever call closeConnect() from within connect() since the link identifier variable only exists within the scope of that method.
__________________
The first rule of Tautology Club is the first rule of Tautology Club. |
|
#3
|
|||
|
|||
|
Mindzai could you give me an example?
|
|
#4
|
||||
|
||||
|
Here's a quick (and untested) cut at how you might approach it:
PHP Code:
__________________
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be." ~ Terry Pratchett in Nation Kindle Minds (blog about Amazon Kindle) |
|
#5
|
||||
|
||||
|
PS: You could use the MySQLi extension in object-oriented mode and not have to create your own class.
__________________
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be." ~ Terry Pratchett in Nation Kindle Minds (blog about Amazon Kindle) |
![]() |
| Bookmarks |
| Tags |
| class, close connection, function, oop |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|