Can you please tell me what these lines of code do?

$sub_category = 0;
            if (!empty($_POST['sub_category_id'])) {
                $is_found = $db->where('type',PT_Secure($_POST['category_id']))->where('lang_key',PT_Secure($_POST['sub_category_id']))->getValue(T_LANGS,'COUNT(*)');
                if ($is_found > 0) {
                    $sub_category = PT_Secure($_POST['sub_category_id']);
                }
            }

I look forward to any assistance

// Set the value of the $sub_category variable to zero.
$sub_category = 0;

// Check if the sub_category_id field, passed in via an HTTP post request, is empty, and if it's not (e.g. it contains data that is not 0 or FALSE) then execute what's inside this IF block
if (!empty($_POST['sub_category_id'])) {

    // Perform a database query based on some PHP ORM library you're using, and store the results in the
    // $is_found variable; I have absolutely no clue what PT_Secure does, and you are not including it here ...
    // that being said, I do see a COUNT(*) at the end and COUNT(*) on its own returns the number of rows
    // returned by a query ... I just have no idea what PT_Secure is and if it changes the data at all
    $is_found = $db->where('type',PT_Secure($_POST['category_id']))->where('lang_key',PT_Secure($_POST['sub_category_id']))->getValue(T_LANGS,'COUNT(*)');

    // If the $is_found variable is greater than zero then execute what's in this IF block
    if ($is_found > 0) {

        // Set the $sub_category variable to <something> but again, I have no idea what PT_Secure() does
        $sub_category = PT_Secure($_POST['sub_category_id']);
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.