// ACTIVAR EL AUTOLOADER DE CLASES Y FICHEROS A INCLUIR
// ---------------------------------------------------------------
define("APP_PATH", $_SERVER['DOCUMENT_ROOT'] . $app['path'] . "/");
include_once "../" . $app['framework'] . "Autoloader.class.php";
Autoloader::setCacheFilePath(APP_PATH . 'tmp/class_path_cache.txt');
Autoloader::excludeFolderNamesMatchingRegex('/^CVS|\\..*$/');
Autoloader::setClassPaths(array('../' . $app['framework'], '../entities/', '../lib/'));
spl_autoload_register(array('Autoloader', 'loadClass'));
$v = $_GET;
$tabla = new FamiliasPropiedades();
$rows = $tabla->cargaCondicion("Id", "IDFamilia='{$v['idFamilia']}' and IDPropiedad='{$v['idPropiedad']}'");
$idRelacion = $rows[0]['Id'];
if (!$idRelacion) {
    // Hacer relacion
    if ($v['valor']) {
        $relacion = new FamiliasPropiedades();
        $relacion->setIDFamilia($v['idFamilia']);
        $relacion->setIDPropiedad($v['idPropiedad']);
        $relacion->setFiltrable(1);
        $relacion->setPublish(1);
        $relacion->create();
    }
} else {
    $relacion = new FamiliasPropiedades($idRelacion);
    $relacion->setFiltrable($v['valor']);
    $relacion->save();
}
unset($tabla);
unset($relacion);
$tag = "";
echo $tag;