About your points:
1) Absolutely correct. Die was a bad choice. But usually when it reaches deployment stage, your queries should be correct by then. die is more of a help during development.
2) Didn't follow you there. Can you rephrase?
3) Noted.
4) hmm, i never saw or used phpdoc. I wrote them the way i used to do with javadoc. Didn't think there would be any difference really.
5) Noted.
6) That actually never crossed my mind. I never had to connect to more than one database, and that option didn't occur to me.
7) I wrote the entire file primarily because of my need for db_1row and db_0or1row. I needed some way to detect during development if my queries are returning the correct number of rows. I chose a class, simply because i never wrote OO PHP before, and decided to take a go at it. You think a lib file would be more appropriate in this case?
And thanx for your feedback, extremely valuable. :)
On 9/20/06, Ala'a Ibrahim <[EMAIL PROTECTED]
> wrote:
ok,
Just taking a look at your class, before testing it, I have some points
1. Use of die:Well usually this is not the action the programmer want, if the connection fails, I'd like to handle it in another way, not to crash my whole application, you can throw an exception instead, it's preferable that you extend your own exception for eas of use.2. Using MySQL Library:
e.g. DBConnectionException extends Exception {}; DBSqlException extends Exception {};
you are using PHP5 !Mysql 5 is up there for a lot of time, we use Stored Procedures, MySQL extention is not that good in handling Stored Procedure, as if you have a stored procedure containing a Select Statement to output data, you would have an error calling it, Although MySQLi is available for it, and you can make use of all the features that it comes with.3. line 123 - Error:return mysq_insert_id(); // it should be return mysql_insert_id();4. PHPDoc Tags Need to be fixed:
e.g. @param $database => @param string $database // you should specify the data-type of the parameter5. testing with null using ==:
@return A mysql result set. => @return resource A mysql result set. // Same as above
some functions like db_1row returns a value but no @return is there.the first thing == doesn't check on type, so "" == null is true also 0 == null is true, so you can use the === operator, but when it comes to null, it's always better to use !isset instead.6. More than a database connection:Well, if I'm connecting to more than one server in one page, your class fails in this area, I guess it's so obvious why7. What Does it do exactly:Well, taking a look at this class, the question I asked my self is what this class actually do, it does not give me an abstraction of MySql Database, it doesn't handle connections, it doesn't keep track of it, it only tracks on a result, so if that what is supposed to do you can make it a static class, or even a library with several functions that you might use.
I know I'm annoying here, but you are the one who asked :POn 9/20/06, Al-Faisal El-Dajani <[EMAIL PROTECTED] > wrote:Hey all,
I just wrote this class for database connectivity. Can somebody plz help in testing? Any ideas or suggestions would be great.
Thanx
PS: Requires PHP 5
--
Al-Faisal El-Dajani
Tel: +962-7-77 799 781
P.O Box: 140056
11814 Amman, Jordan
--
Al-Faisal El-Dajani
Tel: +962-7-77 799 781
P.O Box: 140056
11814 Amman, Jordan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Jordan PHP Users Group" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/JoPHP
http://Jolug.org/
-~----------~----~----~----~------~----~------~--~---
