PHP Classes

The connect method has a bug, it returns the connection befor...

Recommend this page to a friend!

      MySQL-wrapper  >  All threads  >  The connect method has a bug, it...  >  (Un) Subscribe thread alerts  
Subject:The connect method has a bug, it...
Summary:Package rating comment
Messages:1
Author:Timo Reitz
Date:2010-02-26 11:22:25
 

 

Timo Reitz rated this package as follows:

Utility: Bad
Consistency: Sufficient

  1. The connect method has a bug, it...   Reply   Report abuse  
Picture of Timo Reitz Timo Reitz - 2010-02-26 11:22:26
The connect method has a bug, it returns the connection before setting the database, rendering the corresponding argument useless. This avoids just another bug, where instead of mysql_select_db the inexistent mysql_selected_db is used.

The try-catch-blocks scattered around are silly, because the mysql_* functions do not throw exceptions. Even if they did, the error handling would be pointless, because just echoing the exception is very bad practice, it prevents logging.

The PHP manual recommends using the database-specific escaping functions, in this case mysql_real_escape_string, instead of the generic addslashes.

In the select method is a bug:
strlen( $where_sql - 5 )
Obviously, this should have been:
strlen ( $where_sql ) - 5

And another, more architectural thing If I'd need more than one database connection, how could I use the class?

 
For more information send a message to info at phpclasses dot org.