DropdownTranslation::getTranslationID PHP Method

getTranslationID() static public method

Get the id of a translated string
static public getTranslationID ( $ID, $itemtype, $field, $language ) : the
$ID item id
$itemtype item type
$field the field for which the translation is needed
$language the target language
return the row id or 0 if not translation found
    static function getTranslationID($ID, $itemtype, $field, $language)
    {
        global $DB;
        $query = "SELECT `id`\n                  FROM `" . self::getTable() . "`\n                  WHERE `itemtype` = '" . $itemtype . "'\n                        AND `items_id` = '" . $ID . "'\n                        AND `language` = '{$language}'\n                        AND `field` = '{$field}'";
        $results = $DB->query($query);
        if ($DB->numrows($results)) {
            return $DB->result($results, 0, 'id');
        }
        return 0;
    }