Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
948 views
in Q2A Core by

I am very curious why gidgreen decided to implement:

    function qa_db_read_one_value($result, $allowempty=false)

And why not directly:

    function qa_db_read_one_value($result)

while throwing back "null" if there are no results.


Why am I asking?

I too often forget to add a "true" in the end of the query! Arbitrary example:

        qa_db_read_one_value(qa_db_query_sub(
            'SELECT parentid FROM ^categories WHERE categoryid=#',
            $categoryid
        ));

If there is no parentid, instead of NULL we get an error message and the script breaks at this point.

Thanks,
Kai

1 Answer

+1 vote
by
Just got the answer by myself again:

There could be a value that is NULL in the database. Having NULL as default throwback would "tell" that a value exists with the value NULL even though if it doesn't.

I think that is the idea behind.
...