* Return number of active users in database $table
* @param $table
* @return mixed|null
* @param string $table
* @return string
*/
functionqa_db_count_active_users($table)
{
...
...
@@ -124,6 +127,7 @@ function qa_db_count_active_users($table)
/**
* Return number of categories in the database
* @return string
*/
functionqa_db_count_categories()
{
...
...
@@ -135,8 +139,8 @@ function qa_db_count_categories()
/**
* Return number of questions in the database in $categoryid exactly, and not one of its subcategories
* @param $categoryid
* @return mixed|null
* @param int $categoryid
* @return string
*/
functionqa_db_count_categoryid_qs($categoryid)
{
...
...
@@ -149,7 +153,7 @@ function qa_db_count_categoryid_qs($categoryid)
/**
* Return list of postids of visible or queued posts by $userid
* @param $userid
* @param mixed $userid
* @return array
*/
functionqa_db_get_user_visible_postids($userid)
...
...
@@ -163,7 +167,7 @@ function qa_db_get_user_visible_postids($userid)
/**
* Return list of postids of visible or queued posts from $ip address
* @param $ip
* @param string $ip
* @return array
*/
functionqa_db_get_ip_visible_postids($ip)
...
...
@@ -177,12 +181,12 @@ function qa_db_get_ip_visible_postids($ip)
/**
* Return an array whose keys contain the $postids which exist, and whose elements contain the number of other posts depending on each one
* @param $postids
* @param array $postids
* @return array
*/
functionqa_db_postids_count_dependents($postids)
{
if(count($postids))
if(!empty($postids))
returnqa_db_read_all_assoc(qa_db_query_sub(
"SELECT postid, COALESCE(childcount, 0) AS count FROM ^posts LEFT JOIN (SELECT parentid, COUNT(*) AS childcount FROM ^posts WHERE parentid IN (#) AND LEFT(type, 1) IN ('A', 'C') GROUP BY parentid) x ON postid=x.parentid WHERE postid IN (#)",
$postids,$postids
...
...
@@ -195,7 +199,7 @@ function qa_db_postids_count_dependents($postids)
/**
* Return an array of the (up to) $count most recently created users who are awaiting approval and have not been blocked.
* The array element for each user includes a 'profile' key whose value is an array of non-empty profile fields of the user.
* @param $count
* @param int $count
* @return array
*/
functionqa_db_get_unapproved_users($count)
...
...
@@ -227,6 +231,7 @@ function qa_db_get_unapproved_users($count)
/**
* Return whether there are any blobs whose content has been stored as a file on disk
* @return bool
*/
functionqa_db_has_blobs_on_disk()
{
...
...
@@ -236,6 +241,7 @@ function qa_db_has_blobs_on_disk()
/**
* Return whether there are any blobs whose content has been stored in the database
* @return bool
*/
functionqa_db_has_blobs_in_db()
{
...
...
@@ -245,8 +251,8 @@ function qa_db_has_blobs_in_db()
/**
* Return the maximum position of the categories with $parentid
* @param $parentid
* @return mixed|null
* @param int $parentid
* @return string
*/
functionqa_db_category_last_pos($parentid)
{
...
...
@@ -259,7 +265,7 @@ function qa_db_category_last_pos($parentid)
/**
* Return how many levels of subcategory there are below $categoryid
* @param $categoryid
* @param int $categoryid
* @return int
*/
functionqa_db_category_child_depth($categoryid)
...
...
@@ -283,18 +289,18 @@ function qa_db_category_child_depth($categoryid)
/**
* Create a new category with $parentid, $title (=name) and $tags (=slug) in the database