Page 1 of 1
Wrong behaviour in serendipity_db_query()?
Posted: Fri Jan 07, 2011 4:52 pm
by WebComPas
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
Re: Wrong behaviour in serendipity_db_query()?
Posted: Fri Jan 07, 2011 11:20 pm
by garvinhicking
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
Re: Wrong behaviour in serendipity_db_query()?
Posted: Sat Jan 08, 2011 2:30 pm
by WebComPas
I'm referring to the PHPDoc documentation within the mysql.inc.php:
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]
None of these possible return value descriptions says that in case of an error a string containing the error message will be returned.
Re: Wrong behaviour in serendipity_db_query()?
Posted: Sat Jan 08, 2011 8:59 pm
by garvinhicking
Hi!
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:
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]
None of these possible return value descriptions says that in case of an error a string containing the error message will be returned.
Re: Wrong behaviour in serendipity_db_query()?
Posted: Sat Jan 08, 2011 9:20 pm
by WebComPas
OK, thank you! Surely this will be helpful for developers which are not familiar with this function.
Regards
Pascal