Hallo!
Yesterday I found a strange behaviour of the core function serendipity_db_query(): According to the documentation it should return FALSE if an error occurs but in fact it returns the error message.
Can anyone tell me if this is a bug or if I didn't understand this correctly?
Regards,
Pascal
Wrong behaviour in serendipity_db_query()?
Wrong behaviour in serendipity_db_query()?
Interessantes aus den Themenbereichen Computer, Internet und Programmierung unter http://www.it-blog.net
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Wrong behaviour in serendipity_db_query()?
Hi!
Which documentation are you referring to? false is returned when no database connection exists; it also returns false when the "expect_error" variable is set to true. Else when an error occurs, it returns a string for the actual error.
I do agree this behaviour is a bit unfortunate, but since some API functions already depend on it, you should best check for an is_string() return code; or set the expect_error accordingly?
HTH,
Garvin
Which documentation are you referring to? false is returned when no database connection exists; it also returns false when the "expect_error" variable is set to true. Else when an error occurs, it returns a string for the actual error.
I do agree this behaviour is a bit unfortunate, but since some API functions already depend on it, you should best check for an is_string() return code; or set the expect_error accordingly?
HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: Wrong behaviour in serendipity_db_query()?
I'm referring to the PHPDoc documentation within the mysql.inc.php:
None of these possible return value descriptions says that in case of an error a string containing the error message will be returned.It can return:
* false if there was an error,
* true if the query succeeded but did not generate any rows
* array of field values if it returned a single row and $single is true
* array of array of field values if it returned row(s) [stacked array]
Interessantes aus den Themenbereichen Computer, Internet und Programmierung unter http://www.it-blog.net
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Wrong behaviour in serendipity_db_query()?
Hi!
Ah, that's true. Then somebody simply messed up documenting, and I'll fix this in SVN
Regards,
Garvin
Ah, that's true. Then somebody simply messed up documenting, and I'll fix this in SVN
Regards,
Garvin
WebComPas wrote:I'm referring to the PHPDoc documentation within the mysql.inc.php:None of these possible return value descriptions says that in case of an error a string containing the error message will be returned.It can return:
* false if there was an error,
* true if the query succeeded but did not generate any rows
* array of field values if it returned a single row and $single is true
* array of array of field values if it returned row(s) [stacked array]
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: Wrong behaviour in serendipity_db_query()?
OK, thank you! Surely this will be helpful for developers which are not familiar with this function.
Regards
Pascal
Regards
Pascal
Interessantes aus den Themenbereichen Computer, Internet und Programmierung unter http://www.it-blog.net