protected static function linkMediaToModule($media_id, $module, $other_id, $identifier = "") { $db = FrontendModel::getDB(true); //--Calculate sequence $sequence = (int) $db->getVar('SELECT MAX(i.sequence) FROM media_modules AS i WHERE i.module = ? AND other_id = ? and identifier = ?', array((int) $module, $other_id, $identifier)); $sequence += 1; $insert = array(); $insert["media_id"] = $media_id; $insert["module"] = $module; $insert["other_id"] = $other_id; $insert["identifier"] = $identifier; $insert["sequence"] = $sequence; $insert["language"] = FRONTEND_LANGUAGE; $insert["text"] = ""; $insert["linktype"] = 0; //--Add record to db return $db->insert("media_modules", $insert); }