![]() |
Am I on the right track with OOP?
I havent programmed with PHP in over a year and Im starting again, by jumping into OOP, something I never really used before... kinda confused me at first, working on a mysql class. Anyways, heres what I have for the connection, is this complete sloppyness? or acceptable?
testmysql.php :
<?phpmysql.php :
<?phpI wrote the connect to select the database too because my scripts only using 1 database and it would be quite an annoyance to have to have an extra line in every file to select the database. How does it look? |
What is this? (rearranged for logical clarity)
:
if (!$dblink) :
if ($dblink && !mysql_select_db ($this->dbname, $dblink)) $dblink = false; |
Alrighty, thanks, I see what your saying.
I have another question... I have the mysqldb class, and now I have a validateuser class. The valideuserclass looks like this currently: :
<?phpThats just a simple function to start off to see if the username and password's are valid. This class is right after the mysqldb class. The problem is when it extends the mysql class, all the vars in that class are dropped, as is the connection var, so all querys fail unless I fill out the connection again, and its just too sloppy to do that over and over again and start another connection, that is beyond out of the question. Is there any other way I can use the mysql classes functions within that, without extending it? |
Quote:
- Sean |
| All times are GMT -5. The time now is 1:37 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC